# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
609587 | 2022-07-27T17:41:22 Z | Plurm | Bali Sculptures (APIO15_sculpture) | C++11 | 490 ms | 4340 KB |
#include <bits/stdc++.h> using namespace std; int y[2048]; int dp[2048]; bool check[2048][2048]; long long dps[2048][2048]; long long qs[2048]; int main() { int n, a, b; scanf("%d%d%d", &n, &a, &b); for (int i = 1; i <= n; i++) { scanf("%d", y + i); qs[i] = qs[i - 1] + y[i]; } if (a == 1) { long long oldmask = 0ll; for (long long bit = 60; bit >= 0; bit--) { long long mask = oldmask | ((1ll << bit) - 1ll); for (int i = 1; i <= n; i++) { long long sum = 0ll; for (int j = i; j <= n; j++) { sum += y[j]; check[i][j] = (sum | mask) == mask; } } for (int i = 1; i <= n; i++) { if (check[1][i]) dp[i] = 1; else dp[i] = 1e9; for (int j = 1; j < i; j++) { if (check[j + 1][i]) { dp[i] = min(dp[j] + 1, dp[i]); } } } if (dp[n] > b) { oldmask |= 1ll << bit; } } printf("%lld\n", oldmask); } else { for (int k = 1; k <= b; k++) { for (int i = 1; i <= n; i++) { dps[k][i] = 1e18; for (int j = 1; j < i; j++) { dps[k][i] = min(dps[k][i], dps[k - 1][j] | (qs[i] - qs[j - 1])); } } } long long mn = 1e18; for (int k = a; k <= b; k++) { mn = min(mn, dps[k][n]); } printf("%lld\n", mn); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Incorrect | 0 ms | 212 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Incorrect | 0 ms | 212 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 468 KB | Output is correct |
27 | Correct | 1 ms | 468 KB | Output is correct |
28 | Correct | 2 ms | 468 KB | Output is correct |
29 | Correct | 2 ms | 468 KB | Output is correct |
30 | Correct | 2 ms | 468 KB | Output is correct |
31 | Correct | 2 ms | 468 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Incorrect | 0 ms | 212 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 1 ms | 468 KB | Output is correct |
37 | Correct | 1 ms | 468 KB | Output is correct |
38 | Correct | 1 ms | 468 KB | Output is correct |
39 | Correct | 2 ms | 468 KB | Output is correct |
40 | Correct | 2 ms | 468 KB | Output is correct |
41 | Correct | 1 ms | 468 KB | Output is correct |
42 | Correct | 2 ms | 468 KB | Output is correct |
43 | Correct | 1 ms | 340 KB | Output is correct |
44 | Correct | 1 ms | 468 KB | Output is correct |
45 | Correct | 2 ms | 468 KB | Output is correct |
46 | Correct | 2 ms | 468 KB | Output is correct |
47 | Correct | 2 ms | 468 KB | Output is correct |
48 | Correct | 2 ms | 468 KB | Output is correct |
49 | Correct | 2 ms | 468 KB | Output is correct |
50 | Correct | 2 ms | 468 KB | Output is correct |
51 | Correct | 2 ms | 468 KB | Output is correct |
52 | Correct | 37 ms | 1452 KB | Output is correct |
53 | Correct | 58 ms | 1748 KB | Output is correct |
54 | Correct | 108 ms | 2428 KB | Output is correct |
55 | Correct | 114 ms | 2316 KB | Output is correct |
56 | Correct | 455 ms | 4328 KB | Output is correct |
57 | Correct | 436 ms | 4332 KB | Output is correct |
58 | Correct | 449 ms | 4328 KB | Output is correct |
59 | Correct | 466 ms | 4340 KB | Output is correct |
60 | Correct | 445 ms | 4328 KB | Output is correct |
61 | Correct | 2 ms | 468 KB | Output is correct |
62 | Correct | 67 ms | 1748 KB | Output is correct |
63 | Correct | 110 ms | 2260 KB | Output is correct |
64 | Correct | 113 ms | 2320 KB | Output is correct |
65 | Correct | 208 ms | 3136 KB | Output is correct |
66 | Correct | 330 ms | 3820 KB | Output is correct |
67 | Correct | 420 ms | 4324 KB | Output is correct |
68 | Correct | 490 ms | 4328 KB | Output is correct |
69 | Correct | 434 ms | 4332 KB | Output is correct |