# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
453156 | 2021-08-04T08:22:22 Z | nonsensenonsense1 | Bali Sculptures (APIO15_sculpture) | C++17 | 295 ms | 324 KB |
#include <cstdio> #include <algorithm> const int LG = 60; const int N1 = 100; const int N2 = 2000; int n, a, b, y[N2], mn[N2 + 1]; bool d[N1 + 1][N1 + 1]; inline bool good(long long s, long long x, int l) { return ((x | s) & ~(((long long)1 << l) - 1)) == x; } bool test1(long long x, int l) { for (int i = 1; i <= n; ++i) for (int j = 1; j <= i; ++j) { d[i][j] = 0; long long s = 0; for (int k = i - 1; k >= 0; --k) { s += y[k]; if (good(s, x, l)) d[i][j] = d[i][j] || d[k][j - 1]; } if (i == n && j >= a && j <= b && d[i][j]) return true; } return false; } bool test2(long long x, int l) { for (int i = 1; i <= n; ++i) { mn[i] = n + 1; long long s = 0; for (int j = i - 1; j >= 0; --j) { s += y[j]; if (good(s, x, l)) mn[i] = std::min(mn[i], mn[j] + 1); } } return mn[n] <= b; } int main() { scanf("%d%d%d", &n, &a, &b); for (int i = 0; i < n; ++i) scanf("%d", y + i); long long ans = 0; d[0][0] = 1; for (int i = LG - 1; i >= 0; --i) if (a != 1 && !test1(ans, i) || a == 1 && !test2(ans, i)) ans |= (long long)1 << i; printf("%lld\n", ans); return 0; }
Compilation message
# | 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 | 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 | 1 ms | 204 KB | Output is correct |
16 | Correct | 0 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 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 | 204 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 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 | 0 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 | 204 KB | Output is correct |
34 | Correct | 0 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 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 | 0 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 0 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 204 KB | Output is correct |
25 | Correct | 2 ms | 204 KB | Output is correct |
26 | Correct | 3 ms | 204 KB | Output is correct |
27 | Correct | 0 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 | 1 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 204 KB | Output is correct |
33 | Correct | 1 ms | 204 KB | Output is correct |
34 | Correct | 1 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 1 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 | 1 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 | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 204 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 | 204 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 204 KB | Output is correct |
23 | Correct | 1 ms | 204 KB | Output is correct |
24 | Correct | 1 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 1 ms | 204 KB | Output is correct |
28 | Correct | 1 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 | 2 ms | 204 KB | Output is correct |
32 | Correct | 1 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 | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 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 | 0 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 0 ms | 204 KB | Output is correct |
17 | Correct | 0 ms | 204 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 | 204 KB | Output is correct |
21 | Correct | 1 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 216 KB | Output is correct |
23 | Correct | 1 ms | 216 KB | Output is correct |
24 | Correct | 1 ms | 204 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 0 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 | 204 KB | Output is correct |
34 | Correct | 0 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 0 ms | 204 KB | Output is correct |
37 | Correct | 0 ms | 204 KB | Output is correct |
38 | Correct | 1 ms | 236 KB | Output is correct |
39 | Correct | 1 ms | 204 KB | Output is correct |
40 | Correct | 1 ms | 204 KB | Output is correct |
41 | Correct | 1 ms | 204 KB | Output is correct |
42 | Correct | 1 ms | 204 KB | Output is correct |
43 | Correct | 1 ms | 204 KB | Output is correct |
44 | Correct | 1 ms | 204 KB | Output is correct |
45 | Correct | 1 ms | 204 KB | Output is correct |
46 | Correct | 1 ms | 204 KB | Output is correct |
47 | Correct | 1 ms | 204 KB | Output is correct |
48 | Correct | 1 ms | 204 KB | Output is correct |
49 | Correct | 1 ms | 204 KB | Output is correct |
50 | Correct | 1 ms | 204 KB | Output is correct |
51 | Correct | 2 ms | 204 KB | Output is correct |
52 | Correct | 2 ms | 204 KB | Output is correct |
53 | Correct | 2 ms | 204 KB | Output is correct |
54 | Correct | 2 ms | 204 KB | Output is correct |
55 | Correct | 2 ms | 204 KB | Output is correct |
56 | Correct | 1 ms | 204 KB | Output is correct |
57 | Correct | 1 ms | 204 KB | Output is correct |
58 | Correct | 1 ms | 204 KB | Output is correct |
59 | Correct | 1 ms | 204 KB | Output is correct |
60 | Correct | 1 ms | 204 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 | 37 ms | 288 KB | Output is correct |
65 | Correct | 6 ms | 204 KB | Output is correct |
66 | Correct | 11 ms | 280 KB | Output is correct |
67 | Correct | 19 ms | 284 KB | Output is correct |
68 | Correct | 34 ms | 204 KB | Output is correct |
69 | Correct | 40 ms | 288 KB | Output is correct |
70 | Correct | 37 ms | 204 KB | Output is correct |
71 | Correct | 66 ms | 324 KB | Output is correct |
72 | Correct | 95 ms | 204 KB | Output is correct |
73 | Correct | 38 ms | 204 KB | Output is correct |
74 | Correct | 38 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 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 | 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 | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 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 | 204 KB | Output is correct |
17 | Correct | 0 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 0 ms | 204 KB | Output is correct |
21 | Correct | 0 ms | 204 KB | Output is correct |
22 | Correct | 0 ms | 204 KB | Output is correct |
23 | Correct | 1 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 | 204 KB | Output is correct |
27 | Correct | 2 ms | 204 KB | Output is correct |
28 | Correct | 1 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 | 204 KB | Output is correct |
33 | Correct | 1 ms | 204 KB | Output is correct |
34 | Correct | 1 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 204 KB | Output is correct |
36 | Correct | 1 ms | 204 KB | Output is correct |
37 | Correct | 1 ms | 204 KB | Output is correct |
38 | Correct | 1 ms | 204 KB | Output is correct |
39 | Correct | 2 ms | 204 KB | Output is correct |
40 | Correct | 2 ms | 204 KB | Output is correct |
41 | Correct | 1 ms | 204 KB | Output is correct |
42 | Correct | 1 ms | 204 KB | Output is correct |
43 | Correct | 2 ms | 204 KB | Output is correct |
44 | Correct | 1 ms | 204 KB | Output is correct |
45 | Correct | 3 ms | 204 KB | Output is correct |
46 | Correct | 1 ms | 204 KB | Output is correct |
47 | Correct | 1 ms | 204 KB | Output is correct |
48 | Correct | 1 ms | 204 KB | Output is correct |
49 | Correct | 1 ms | 204 KB | Output is correct |
50 | Correct | 1 ms | 204 KB | Output is correct |
51 | Correct | 3 ms | 204 KB | Output is correct |
52 | Correct | 23 ms | 204 KB | Output is correct |
53 | Correct | 37 ms | 204 KB | Output is correct |
54 | Correct | 70 ms | 276 KB | Output is correct |
55 | Correct | 65 ms | 272 KB | Output is correct |
56 | Correct | 252 ms | 272 KB | Output is correct |
57 | Correct | 289 ms | 296 KB | Output is correct |
58 | Correct | 291 ms | 324 KB | Output is correct |
59 | Correct | 240 ms | 300 KB | Output is correct |
60 | Correct | 285 ms | 296 KB | Output is correct |
61 | Correct | 2 ms | 204 KB | Output is correct |
62 | Correct | 59 ms | 284 KB | Output is correct |
63 | Correct | 75 ms | 296 KB | Output is correct |
64 | Correct | 74 ms | 288 KB | Output is correct |
65 | Correct | 135 ms | 204 KB | Output is correct |
66 | Correct | 204 ms | 292 KB | Output is correct |
67 | Correct | 295 ms | 292 KB | Output is correct |
68 | Correct | 254 ms | 292 KB | Output is correct |
69 | Correct | 277 ms | 288 KB | Output is correct |