Submission #529357

# Submission time Handle Problem Language Result Execution time Memory
529357 2022-02-22T20:46:09 Z Hanksburger Bali Sculptures (APIO15_sculpture) C++17
100 / 100
76 ms 820 KB
#include <bits/stdc++.h>
using namespace std;
long long dp1[2005][2005], dp2[2005], a[2005], b[2005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long n, l, r, x, loog=0, cur=0;
	cin >> n >> l >> r;
	for (long long i=1; i<=n; i++)
		cin >> a[i];
	for (long long i=1; i<=n; i++)
		b[i]=b[i-1]+a[i];
	x=b[n];
	while (x)
	{
		x>>=1;
		loog++;
	}
	if (l==1)
	{
		for (long long i=loog-1; i>=0; i--)
		{
			cur|=1LL<<i;
			for (long long j=0; j<=n; j++)
				dp2[j]=1e18;
			dp2[0]=0;
			for (long long j=1; j<=n; j++)
				for (long long k=0; k<j; k++)
					if (!(cur&(b[j]-b[k])))
						dp2[j]=min(dp2[j], dp2[k]+1);
			if (dp2[n]>r)
				cur^=1LL<<i;
		}
	}
	else
	{
		for (long long i=loog-1; i>=0; i--)
		{
			cur|=1LL<<i;
			for (long long j=0; j<=n; j++)
				for (long long k=0; k<=n; k++)
					dp1[j][k]=0;
			dp1[0][0]=1;
			for (long long j=1; j<=n; j++)
			{
				for (long long k=1; k<=j; k++)
				{
					for (long long m=0; m<j; m++)
						if (!(cur&(b[j]-b[m])) && dp1[m][k-1])
							dp1[j][k]=1;
				}
			}
			bool imp=1;
			for (long long i=l; i<=r; i++)
			{
				if (dp1[n][i])
				{
					imp=0;
					break;
				}
			}
			if (imp)
				cur^=1LL<<i;
		}
	}
	cout << (1LL<<loog)-cur-1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 300 KB Output is correct
29 Correct 0 ms 324 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 324 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 332 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 232 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 1 ms 328 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 0 ms 316 KB Output is correct
35 Correct 0 ms 336 KB Output is correct
36 Correct 0 ms 336 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 0 ms 324 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 0 ms 332 KB Output is correct
48 Correct 0 ms 332 KB Output is correct
49 Correct 0 ms 312 KB Output is correct
50 Correct 0 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 320 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 0 ms 332 KB Output is correct
56 Correct 0 ms 204 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 KB Output is correct
60 Correct 1 ms 324 KB Output is correct
61 Correct 1 ms 204 KB Output is correct
62 Correct 1 ms 204 KB Output is correct
63 Correct 1 ms 204 KB Output is correct
64 Correct 3 ms 708 KB Output is correct
65 Correct 3 ms 452 KB Output is correct
66 Correct 5 ms 588 KB Output is correct
67 Correct 8 ms 588 KB Output is correct
68 Correct 12 ms 716 KB Output is correct
69 Correct 16 ms 820 KB Output is correct
70 Correct 16 ms 716 KB Output is correct
71 Correct 17 ms 816 KB Output is correct
72 Correct 17 ms 716 KB Output is correct
73 Correct 15 ms 720 KB Output is correct
74 Correct 15 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 276 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 324 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 320 KB Output is correct
38 Correct 0 ms 324 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 320 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 324 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 7 ms 332 KB Output is correct
53 Correct 10 ms 360 KB Output is correct
54 Correct 19 ms 332 KB Output is correct
55 Correct 19 ms 332 KB Output is correct
56 Correct 66 ms 460 KB Output is correct
57 Correct 65 ms 372 KB Output is correct
58 Correct 64 ms 372 KB Output is correct
59 Correct 66 ms 332 KB Output is correct
60 Correct 76 ms 388 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 10 ms 348 KB Output is correct
63 Correct 20 ms 332 KB Output is correct
64 Correct 18 ms 368 KB Output is correct
65 Correct 33 ms 332 KB Output is correct
66 Correct 55 ms 364 KB Output is correct
67 Correct 70 ms 332 KB Output is correct
68 Correct 73 ms 332 KB Output is correct
69 Correct 70 ms 348 KB Output is correct