# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
110223 | 2019-05-10T08:43:23 Z | SamAnd | Bali Sculptures (APIO15_sculpture) | C++17 | 1000 ms | 14612 KB |
#include <bits/stdc++.h> using namespace std; const int N = 2003, M = 102; int n; int ll, rr; int a[N]; void solv0() { long long ans = (1LL << 62); for (int x = 0; x < (1 << n); ++x) { if ((x & (1 << 0)) == 0) continue; vector<long long> v; long long y = a[1]; for (int i = 1; i < n; ++i) { if ((x & (1 << i))) { v.push_back(y); y = a[i + 1]; } else y += a[i + 1]; } v.push_back(y); long long yans = 0; for (int i = 0; i < v.size(); ++i) yans = yans | v[i]; if (ll <= v.size() && v.size() <= rr) ans = min(ans, yans); } cout << ans << endl; } bool dp[M][M][1 << 12] = {}; void solv1() { dp[0][0][0] = true; for (int i = 1; i <= n; ++i) { int s = 0; for (int j = i; j >= 1; --j) { s += a[j]; for (int k = 0; k <= rr; ++k) { for (int x = 0; x < (1 << 12); ++x) { if (!dp[j - 1][k][x]) continue; dp[i][k + 1][x | s] = true; } } } } int ans = (1 << 12); for (int k = ll; k <= rr; ++k) { for (int x = 0; x < (1 << 12); ++x) { if (dp[n][k][x]) ans = min(ans, x); } } cout << ans << endl; } int main() { //freopen("input.txt", "r", stdin); cin >> n >> ll >> rr; for (int i = 1; i <= n; ++i) cin >> a[i]; if (n <= 20) solv0(); else solv1(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 6 ms | 384 KB | Output is correct |
7 | Correct | 19 ms | 384 KB | Output is correct |
8 | Correct | 188 ms | 256 KB | Output is correct |
9 | Correct | 171 ms | 384 KB | Output is correct |
10 | Correct | 137 ms | 256 KB | Output is correct |
11 | Correct | 137 ms | 376 KB | Output is correct |
12 | Correct | 172 ms | 380 KB | Output is correct |
13 | Correct | 150 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 256 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 11 ms | 384 KB | Output is correct |
20 | Correct | 18 ms | 256 KB | Output is correct |
21 | Correct | 134 ms | 376 KB | Output is correct |
22 | Correct | 204 ms | 504 KB | Output is correct |
23 | Correct | 134 ms | 376 KB | Output is correct |
24 | Correct | 150 ms | 364 KB | Output is correct |
25 | Correct | 137 ms | 376 KB | Output is correct |
26 | Correct | 138 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 4 ms | 384 KB | Output is correct |
30 | Correct | 71 ms | 256 KB | Output is correct |
31 | Correct | 135 ms | 376 KB | Output is correct |
32 | Correct | 142 ms | 384 KB | Output is correct |
33 | Correct | 140 ms | 476 KB | Output is correct |
34 | Correct | 149 ms | 384 KB | Output is correct |
35 | Correct | 175 ms | 384 KB | Output is correct |
36 | Correct | 164 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 18 ms | 384 KB | Output is correct |
8 | Correct | 187 ms | 384 KB | Output is correct |
9 | Correct | 147 ms | 384 KB | Output is correct |
10 | Correct | 158 ms | 404 KB | Output is correct |
11 | Correct | 161 ms | 384 KB | Output is correct |
12 | Correct | 169 ms | 376 KB | Output is correct |
13 | Correct | 245 ms | 404 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 3 ms | 332 KB | Output is correct |
19 | Correct | 7 ms | 384 KB | Output is correct |
20 | Correct | 21 ms | 256 KB | Output is correct |
21 | Correct | 149 ms | 256 KB | Output is correct |
22 | Correct | 150 ms | 384 KB | Output is correct |
23 | Correct | 158 ms | 376 KB | Output is correct |
24 | Correct | 185 ms | 256 KB | Output is correct |
25 | Correct | 145 ms | 384 KB | Output is correct |
26 | Correct | 141 ms | 376 KB | Output is correct |
27 | Correct | 18 ms | 1280 KB | Output is correct |
28 | Correct | 15 ms | 1280 KB | Output is correct |
29 | Correct | 16 ms | 1152 KB | Output is correct |
30 | Correct | 69 ms | 2936 KB | Output is correct |
31 | Correct | 103 ms | 3744 KB | Output is correct |
32 | Correct | 118 ms | 3720 KB | Output is correct |
33 | Correct | 12 ms | 768 KB | Output is correct |
34 | Correct | 101 ms | 3832 KB | Output is correct |
35 | Correct | 77 ms | 3320 KB | Output is correct |
36 | Correct | 61 ms | 2396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 8 ms | 384 KB | Output is correct |
7 | Correct | 20 ms | 384 KB | Output is correct |
8 | Correct | 155 ms | 376 KB | Output is correct |
9 | Correct | 167 ms | 376 KB | Output is correct |
10 | Correct | 187 ms | 256 KB | Output is correct |
11 | Correct | 168 ms | 376 KB | Output is correct |
12 | Correct | 174 ms | 504 KB | Output is correct |
13 | Correct | 134 ms | 256 KB | Output is correct |
14 | Correct | 18 ms | 1280 KB | Output is correct |
15 | Correct | 17 ms | 1280 KB | Output is correct |
16 | Correct | 20 ms | 1280 KB | Output is correct |
17 | Correct | 63 ms | 2936 KB | Output is correct |
18 | Correct | 158 ms | 3704 KB | Output is correct |
19 | Correct | 101 ms | 3796 KB | Output is correct |
20 | Correct | 13 ms | 768 KB | Output is correct |
21 | Correct | 102 ms | 3824 KB | Output is correct |
22 | Correct | 109 ms | 3320 KB | Output is correct |
23 | Correct | 48 ms | 2424 KB | Output is correct |
24 | Correct | 92 ms | 3832 KB | Output is correct |
25 | Correct | 79 ms | 3068 KB | Output is correct |
26 | Correct | 256 ms | 6776 KB | Output is correct |
27 | Correct | 828 ms | 14564 KB | Output is correct |
28 | Execution timed out | 1075 ms | 12508 KB | Time limit exceeded |
29 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 6 ms | 256 KB | Output is correct |
7 | Correct | 27 ms | 384 KB | Output is correct |
8 | Correct | 133 ms | 384 KB | Output is correct |
9 | Correct | 136 ms | 376 KB | Output is correct |
10 | Correct | 138 ms | 376 KB | Output is correct |
11 | Correct | 133 ms | 364 KB | Output is correct |
12 | Correct | 185 ms | 384 KB | Output is correct |
13 | Correct | 139 ms | 368 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 3 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 256 KB | Output is correct |
19 | Correct | 7 ms | 256 KB | Output is correct |
20 | Correct | 22 ms | 384 KB | Output is correct |
21 | Correct | 229 ms | 256 KB | Output is correct |
22 | Correct | 160 ms | 384 KB | Output is correct |
23 | Correct | 174 ms | 368 KB | Output is correct |
24 | Correct | 151 ms | 256 KB | Output is correct |
25 | Correct | 165 ms | 256 KB | Output is correct |
26 | Correct | 157 ms | 368 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 256 KB | Output is correct |
29 | Correct | 3 ms | 256 KB | Output is correct |
30 | Correct | 93 ms | 384 KB | Output is correct |
31 | Correct | 167 ms | 384 KB | Output is correct |
32 | Correct | 185 ms | 384 KB | Output is correct |
33 | Correct | 169 ms | 376 KB | Output is correct |
34 | Correct | 150 ms | 384 KB | Output is correct |
35 | Correct | 224 ms | 404 KB | Output is correct |
36 | Correct | 174 ms | 372 KB | Output is correct |
37 | Correct | 18 ms | 1280 KB | Output is correct |
38 | Correct | 15 ms | 1280 KB | Output is correct |
39 | Correct | 17 ms | 1152 KB | Output is correct |
40 | Correct | 58 ms | 2936 KB | Output is correct |
41 | Correct | 110 ms | 3708 KB | Output is correct |
42 | Correct | 104 ms | 3704 KB | Output is correct |
43 | Correct | 11 ms | 768 KB | Output is correct |
44 | Correct | 95 ms | 3704 KB | Output is correct |
45 | Correct | 81 ms | 3448 KB | Output is correct |
46 | Correct | 60 ms | 2424 KB | Output is correct |
47 | Correct | 107 ms | 3832 KB | Output is correct |
48 | Correct | 94 ms | 2936 KB | Output is correct |
49 | Correct | 258 ms | 6944 KB | Output is correct |
50 | Correct | 758 ms | 14612 KB | Output is correct |
51 | Execution timed out | 1086 ms | 13688 KB | Time limit exceeded |
52 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 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 | 6 ms | 256 KB | Output is correct |
7 | Correct | 20 ms | 384 KB | Output is correct |
8 | Correct | 179 ms | 368 KB | Output is correct |
9 | Correct | 164 ms | 504 KB | Output is correct |
10 | Correct | 154 ms | 256 KB | Output is correct |
11 | Correct | 155 ms | 376 KB | Output is correct |
12 | Correct | 218 ms | 368 KB | Output is correct |
13 | Correct | 162 ms | 256 KB | Output is correct |
14 | Correct | 3 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 4 ms | 384 KB | Output is correct |
17 | Correct | 78 ms | 256 KB | Output is correct |
18 | Correct | 140 ms | 376 KB | Output is correct |
19 | Correct | 139 ms | 256 KB | Output is correct |
20 | Correct | 154 ms | 376 KB | Output is correct |
21 | Correct | 137 ms | 256 KB | Output is correct |
22 | Correct | 141 ms | 372 KB | Output is correct |
23 | Correct | 140 ms | 384 KB | Output is correct |
24 | Correct | 18 ms | 1280 KB | Output is correct |
25 | Correct | 19 ms | 1280 KB | Output is correct |
26 | Correct | 19 ms | 1280 KB | Output is correct |
27 | Correct | 58 ms | 2936 KB | Output is correct |
28 | Correct | 89 ms | 3704 KB | Output is correct |
29 | Correct | 104 ms | 3696 KB | Output is correct |
30 | Correct | 12 ms | 768 KB | Output is correct |
31 | Correct | 102 ms | 3704 KB | Output is correct |
32 | Correct | 84 ms | 3320 KB | Output is correct |
33 | Correct | 53 ms | 2424 KB | Output is correct |
34 | Correct | 100 ms | 3832 KB | Output is correct |
35 | Correct | 90 ms | 3024 KB | Output is correct |
36 | Correct | 328 ms | 6876 KB | Output is correct |
37 | Correct | 904 ms | 14588 KB | Output is correct |
38 | Execution timed out | 1069 ms | 11256 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |