# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
109857 | 2019-05-08T07:34:02 Z | PeppaPig | Bali Sculptures (APIO15_sculpture) | C++14 | 473 ms | 4352 KB |
#include <bits/stdc++.h> #define long long long using namespace std; const int N = 2e3+5; int n, A, B; long pref[N]; bool C[N][N]; int main() { scanf("%d %d %d", &n, &A, &B); for(int i = 1; i <= n; i++) scanf("%lld", pref+i), pref[i] += pref[i-1]; if(A == 1) { long ans = 0; for(int b = 62; ~b; b--) { int dp[N]; fill_n(dp, N, 1e9); dp[0] = 0; for(int i = 1; i <= n; i++) for(int j = i; j <= n; j++) { long sum = pref[j] - pref[i-1]; if(!(sum >> b & 1) && ((sum | ans) >> (b + 1)) == (ans >> (b + 1))) dp[j] = min(dp[j], dp[i-1] + 1); } if(dp[n] > B) ans |= 1ll << b; } printf("%lld\n", ans); } else { long ans = 0; for(int b = 62; ~b; b--) { memset(C, false, sizeof C); C[0][0] = true; for(int k = 1; k <= n; k++) for(int i = 1; i <= n; i++) for(int j = i; j <= n; j++) { long sum = pref[j] - pref[i-1]; if(!(sum >> b & 1) && ((sum | ans) >> (b + 1)) == (ans >> (b + 1))) C[j][k] |= C[i-1][k-1]; } bool valid = false; for(int i = A; i <= B; i++) valid |= C[n][i]; if(!valid) ans |= 1ll << b; } printf("%lld\n", ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 19 ms | 4224 KB | Output is correct |
15 | Correct | 18 ms | 4224 KB | Output is correct |
16 | Correct | 16 ms | 4300 KB | Output is correct |
17 | Correct | 20 ms | 4224 KB | Output is correct |
18 | Correct | 17 ms | 4224 KB | Output is correct |
19 | Correct | 20 ms | 4224 KB | Output is correct |
20 | Correct | 21 ms | 4224 KB | Output is correct |
21 | Correct | 19 ms | 4224 KB | Output is correct |
22 | Correct | 19 ms | 4224 KB | Output is correct |
23 | Correct | 20 ms | 4224 KB | Output is correct |
24 | Correct | 19 ms | 4224 KB | Output is correct |
25 | Correct | 18 ms | 4224 KB | Output is correct |
26 | Correct | 20 ms | 4224 KB | Output is correct |
27 | Correct | 2 ms | 256 KB | Output is correct |
28 | Correct | 3 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 256 KB | Output is correct |
35 | Correct | 2 ms | 256 KB | Output is correct |
36 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 356 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 17 ms | 4224 KB | Output is correct |
15 | Correct | 18 ms | 4224 KB | Output is correct |
16 | Correct | 18 ms | 4224 KB | Output is correct |
17 | Correct | 20 ms | 4224 KB | Output is correct |
18 | Correct | 20 ms | 4224 KB | Output is correct |
19 | Correct | 19 ms | 4224 KB | Output is correct |
20 | Correct | 19 ms | 4224 KB | Output is correct |
21 | Correct | 17 ms | 4224 KB | Output is correct |
22 | Correct | 19 ms | 4224 KB | Output is correct |
23 | Correct | 16 ms | 4352 KB | Output is correct |
24 | Correct | 18 ms | 4344 KB | Output is correct |
25 | Correct | 16 ms | 4224 KB | Output is correct |
26 | Correct | 16 ms | 4224 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 256 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 3 ms | 256 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 256 KB | Output is correct |
33 | Correct | 3 ms | 256 KB | Output is correct |
34 | Correct | 3 ms | 256 KB | Output is correct |
35 | Correct | 2 ms | 384 KB | Output is correct |
36 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 300 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 3 ms | 256 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 256 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 3 ms | 384 KB | Output is correct |
28 | Correct | 4 ms | 384 KB | Output is correct |
29 | Correct | 3 ms | 256 KB | Output is correct |
30 | Correct | 3 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 256 KB | Output is correct |
32 | Correct | 4 ms | 300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 284 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 19 ms | 4272 KB | Output is correct |
15 | Correct | 20 ms | 4224 KB | Output is correct |
16 | Correct | 18 ms | 4096 KB | Output is correct |
17 | Correct | 16 ms | 4224 KB | Output is correct |
18 | Correct | 20 ms | 4196 KB | Output is correct |
19 | Correct | 20 ms | 4224 KB | Output is correct |
20 | Correct | 20 ms | 4344 KB | Output is correct |
21 | Correct | 18 ms | 4224 KB | Output is correct |
22 | Correct | 17 ms | 4224 KB | Output is correct |
23 | Correct | 18 ms | 4344 KB | Output is correct |
24 | Correct | 17 ms | 4224 KB | Output is correct |
25 | Correct | 20 ms | 4224 KB | Output is correct |
26 | Correct | 21 ms | 4224 KB | Output is correct |
27 | Correct | 2 ms | 256 KB | Output is correct |
28 | Correct | 2 ms | 256 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 256 KB | Output is correct |
31 | Correct | 2 ms | 256 KB | Output is correct |
32 | Correct | 2 ms | 256 KB | Output is correct |
33 | Correct | 2 ms | 256 KB | Output is correct |
34 | Correct | 2 ms | 384 KB | Output is correct |
35 | Correct | 2 ms | 384 KB | Output is correct |
36 | Correct | 2 ms | 384 KB | Output is correct |
37 | Correct | 2 ms | 384 KB | Output is correct |
38 | Correct | 2 ms | 256 KB | Output is correct |
39 | Correct | 3 ms | 384 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 3 ms | 384 KB | Output is correct |
42 | Correct | 3 ms | 384 KB | Output is correct |
43 | Correct | 2 ms | 384 KB | Output is correct |
44 | Correct | 2 ms | 384 KB | Output is correct |
45 | Correct | 3 ms | 384 KB | Output is correct |
46 | Correct | 3 ms | 384 KB | Output is correct |
47 | Correct | 3 ms | 384 KB | Output is correct |
48 | Correct | 3 ms | 384 KB | Output is correct |
49 | Correct | 3 ms | 256 KB | Output is correct |
50 | Correct | 4 ms | 384 KB | Output is correct |
51 | Correct | 2 ms | 256 KB | Output is correct |
52 | Correct | 3 ms | 384 KB | Output is correct |
53 | Correct | 3 ms | 384 KB | Output is correct |
54 | Correct | 3 ms | 384 KB | Output is correct |
55 | Correct | 3 ms | 384 KB | Output is correct |
56 | Correct | 2 ms | 256 KB | Output is correct |
57 | Correct | 3 ms | 384 KB | Output is correct |
58 | Correct | 3 ms | 256 KB | Output is correct |
59 | Correct | 4 ms | 384 KB | Output is correct |
60 | Correct | 3 ms | 256 KB | Output is correct |
61 | Correct | 3 ms | 256 KB | Output is correct |
62 | Correct | 3 ms | 256 KB | Output is correct |
63 | Correct | 4 ms | 384 KB | Output is correct |
64 | Correct | 167 ms | 4224 KB | Output is correct |
65 | Correct | 35 ms | 4224 KB | Output is correct |
66 | Correct | 51 ms | 4224 KB | Output is correct |
67 | Correct | 80 ms | 4224 KB | Output is correct |
68 | Correct | 109 ms | 4344 KB | Output is correct |
69 | Correct | 138 ms | 4224 KB | Output is correct |
70 | Correct | 133 ms | 4296 KB | Output is correct |
71 | Correct | 110 ms | 4224 KB | Output is correct |
72 | Correct | 143 ms | 4300 KB | Output is correct |
73 | Correct | 141 ms | 4344 KB | Output is correct |
74 | Correct | 169 ms | 4296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 256 KB | Output is correct |
13 | Correct | 3 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 432 KB | Output is correct |
18 | Correct | 3 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 2 ms | 256 KB | Output is correct |
21 | Correct | 3 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 384 KB | Output is correct |
23 | Correct | 2 ms | 256 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 2 ms | 256 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 3 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 256 KB | Output is correct |
30 | Correct | 3 ms | 256 KB | Output is correct |
31 | Correct | 2 ms | 384 KB | Output is correct |
32 | Correct | 3 ms | 384 KB | Output is correct |
33 | Correct | 3 ms | 384 KB | Output is correct |
34 | Correct | 3 ms | 384 KB | Output is correct |
35 | Correct | 3 ms | 384 KB | Output is correct |
36 | Correct | 2 ms | 256 KB | Output is correct |
37 | Correct | 3 ms | 384 KB | Output is correct |
38 | Correct | 4 ms | 384 KB | Output is correct |
39 | Correct | 3 ms | 256 KB | Output is correct |
40 | Correct | 3 ms | 384 KB | Output is correct |
41 | Correct | 3 ms | 384 KB | Output is correct |
42 | Correct | 3 ms | 384 KB | Output is correct |
43 | Correct | 3 ms | 256 KB | Output is correct |
44 | Correct | 3 ms | 384 KB | Output is correct |
45 | Correct | 3 ms | 384 KB | Output is correct |
46 | Correct | 5 ms | 384 KB | Output is correct |
47 | Correct | 3 ms | 256 KB | Output is correct |
48 | Correct | 4 ms | 256 KB | Output is correct |
49 | Correct | 4 ms | 384 KB | Output is correct |
50 | Correct | 4 ms | 384 KB | Output is correct |
51 | Correct | 4 ms | 256 KB | Output is correct |
52 | Correct | 41 ms | 376 KB | Output is correct |
53 | Correct | 68 ms | 384 KB | Output is correct |
54 | Correct | 120 ms | 376 KB | Output is correct |
55 | Correct | 116 ms | 376 KB | Output is correct |
56 | Correct | 473 ms | 416 KB | Output is correct |
57 | Correct | 451 ms | 476 KB | Output is correct |
58 | Correct | 365 ms | 476 KB | Output is correct |
59 | Correct | 215 ms | 384 KB | Output is correct |
60 | Correct | 225 ms | 384 KB | Output is correct |
61 | Correct | 3 ms | 412 KB | Output is correct |
62 | Correct | 66 ms | 384 KB | Output is correct |
63 | Correct | 108 ms | 416 KB | Output is correct |
64 | Correct | 101 ms | 376 KB | Output is correct |
65 | Correct | 213 ms | 384 KB | Output is correct |
66 | Correct | 293 ms | 504 KB | Output is correct |
67 | Correct | 337 ms | 384 KB | Output is correct |
68 | Correct | 347 ms | 412 KB | Output is correct |
69 | Correct | 344 ms | 412 KB | Output is correct |