# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224909 | 2020-04-19T05:19:35 Z | Nightlight | Bali Sculptures (APIO15_sculpture) | C++14 | 15 ms | 4352 KB |
#include <bits/stdc++.h> using namespace std; int N, A, B; long long pre[2005]; bool dp[2005][2005]; long long mask; bitset<2005> valid[2005]; long long ans = (1LL << 42) - 1; bool check(long long T) { return ((T | mask) ^ mask) == 0; } /* bool can(int X) { for(int i = 1; i < N; i++) { for(int j = i + 1; j <= N; j++) { valid[i][j] = check(X, pre[j] - pre[i]); } } //i adalah jumlah ambil //j lokasi sekarang bitset<2005> now[2]; for(int j = 1; j <= N; j++) { if(check(X, pre[j])) { now[1] |= valid[j]; } } int skrg, sblm; for(int i = 2; i <= B; i++) { skrg = i & 1, sblm = !skrg; now[skrg] = 0; for(int j = i; j <= N; j++) { if(now[sblm][j]) { now[skrg] |= valid[j]; } } if(i >= A && now[sblm][N]) return 1; } return 0; }*/ bool can(long long X) { memset(dp, 0, sizeof(dp)); for(int i = 1; i <= N; i++) { dp[1][i] = check(pre[i]); } if(A == 1 && dp[1][N]) return 1; for(int i = 2; i <= B; i++) { for(int j = i; j <= N; j++) { for(int k = i - 1; k < j; k++) { if(check(pre[j] - pre[k])) { dp[i][j] = dp[i - 1][k]; break; } } } if(i >= A && dp[i][N]) return 1; } return 0; } int main() { // freopen("inp", "r", stdin); scanf("%d %d %d", &N, &A, &B); for(int i = 1; i <= N; i++) { scanf("%lld", &pre[i]); pre[i] += pre[i - 1]; } for(int i = 41; i >= 0; i--) { mask = ans - (1LL << i); if(can(i)) { ans -= (1LL << i); } } printf("%lld\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 4224 KB | Output is correct |
2 | Correct | 11 ms | 4096 KB | Output is correct |
3 | Correct | 11 ms | 4224 KB | Output is correct |
4 | Correct | 12 ms | 4224 KB | Output is correct |
5 | Correct | 14 ms | 4224 KB | Output is correct |
6 | Correct | 13 ms | 4352 KB | Output is correct |
7 | Correct | 11 ms | 4224 KB | Output is correct |
8 | Correct | 12 ms | 4224 KB | Output is correct |
9 | Correct | 11 ms | 4224 KB | Output is correct |
10 | Correct | 11 ms | 4352 KB | Output is correct |
11 | Correct | 12 ms | 4224 KB | Output is correct |
12 | Correct | 11 ms | 4224 KB | Output is correct |
13 | Correct | 12 ms | 4224 KB | Output is correct |
14 | Correct | 12 ms | 4224 KB | Output is correct |
15 | Correct | 12 ms | 4352 KB | Output is correct |
16 | Correct | 11 ms | 4224 KB | Output is correct |
17 | Correct | 11 ms | 4224 KB | Output is correct |
18 | Correct | 11 ms | 4224 KB | Output is correct |
19 | Correct | 11 ms | 4224 KB | Output is correct |
20 | Incorrect | 11 ms | 4224 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 4224 KB | Output is correct |
2 | Correct | 12 ms | 4224 KB | Output is correct |
3 | Correct | 12 ms | 4224 KB | Output is correct |
4 | Correct | 12 ms | 4224 KB | Output is correct |
5 | Correct | 14 ms | 4224 KB | Output is correct |
6 | Correct | 11 ms | 4224 KB | Output is correct |
7 | Correct | 11 ms | 4224 KB | Output is correct |
8 | Correct | 12 ms | 4224 KB | Output is correct |
9 | Correct | 11 ms | 4224 KB | Output is correct |
10 | Correct | 11 ms | 4224 KB | Output is correct |
11 | Correct | 11 ms | 4224 KB | Output is correct |
12 | Correct | 11 ms | 4224 KB | Output is correct |
13 | Correct | 11 ms | 4224 KB | Output is correct |
14 | Correct | 11 ms | 4224 KB | Output is correct |
15 | Correct | 11 ms | 4224 KB | Output is correct |
16 | Correct | 11 ms | 4224 KB | Output is correct |
17 | Correct | 11 ms | 4224 KB | Output is correct |
18 | Correct | 13 ms | 4224 KB | Output is correct |
19 | Correct | 11 ms | 4224 KB | Output is correct |
20 | Incorrect | 11 ms | 4224 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 4224 KB | Output is correct |
2 | Correct | 11 ms | 4224 KB | Output is correct |
3 | Correct | 11 ms | 4224 KB | Output is correct |
4 | Correct | 15 ms | 4224 KB | Output is correct |
5 | Correct | 11 ms | 4224 KB | Output is correct |
6 | Correct | 14 ms | 4224 KB | Output is correct |
7 | Correct | 11 ms | 4224 KB | Output is correct |
8 | Correct | 11 ms | 4224 KB | Output is correct |
9 | Correct | 12 ms | 4224 KB | Output is correct |
10 | Correct | 11 ms | 4224 KB | Output is correct |
11 | Correct | 12 ms | 4224 KB | Output is correct |
12 | Correct | 12 ms | 4224 KB | Output is correct |
13 | Correct | 12 ms | 4248 KB | Output is correct |
14 | Correct | 11 ms | 4224 KB | Output is correct |
15 | Correct | 11 ms | 4224 KB | Output is correct |
16 | Correct | 12 ms | 4224 KB | Output is correct |
17 | Correct | 12 ms | 4224 KB | Output is correct |
18 | Correct | 12 ms | 4224 KB | Output is correct |
19 | Correct | 12 ms | 4224 KB | Output is correct |
20 | Correct | 11 ms | 4224 KB | Output is correct |
21 | Correct | 13 ms | 4224 KB | Output is correct |
22 | Correct | 12 ms | 4224 KB | Output is correct |
23 | Correct | 11 ms | 4224 KB | Output is correct |
24 | Correct | 12 ms | 4224 KB | Output is correct |
25 | Incorrect | 11 ms | 4224 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 4224 KB | Output is correct |
2 | Correct | 12 ms | 4224 KB | Output is correct |
3 | Correct | 12 ms | 4352 KB | Output is correct |
4 | Correct | 11 ms | 4224 KB | Output is correct |
5 | Correct | 11 ms | 4212 KB | Output is correct |
6 | Correct | 12 ms | 4224 KB | Output is correct |
7 | Correct | 11 ms | 4224 KB | Output is correct |
8 | Correct | 11 ms | 4224 KB | Output is correct |
9 | Correct | 12 ms | 4352 KB | Output is correct |
10 | Correct | 11 ms | 4224 KB | Output is correct |
11 | Correct | 13 ms | 4224 KB | Output is correct |
12 | Correct | 11 ms | 4224 KB | Output is correct |
13 | Correct | 11 ms | 4224 KB | Output is correct |
14 | Correct | 12 ms | 4224 KB | Output is correct |
15 | Correct | 13 ms | 4224 KB | Output is correct |
16 | Correct | 11 ms | 4224 KB | Output is correct |
17 | Correct | 11 ms | 4224 KB | Output is correct |
18 | Correct | 11 ms | 4224 KB | Output is correct |
19 | Correct | 11 ms | 4224 KB | Output is correct |
20 | Incorrect | 11 ms | 4224 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 4224 KB | Output is correct |
2 | Correct | 12 ms | 4224 KB | Output is correct |
3 | Correct | 11 ms | 4352 KB | Output is correct |
4 | Correct | 12 ms | 4224 KB | Output is correct |
5 | Correct | 12 ms | 4224 KB | Output is correct |
6 | Correct | 15 ms | 4224 KB | Output is correct |
7 | Correct | 11 ms | 4224 KB | Output is correct |
8 | Correct | 11 ms | 4224 KB | Output is correct |
9 | Correct | 11 ms | 4224 KB | Output is correct |
10 | Correct | 11 ms | 4224 KB | Output is correct |
11 | Correct | 12 ms | 4224 KB | Output is correct |
12 | Correct | 11 ms | 4224 KB | Output is correct |
13 | Correct | 11 ms | 4224 KB | Output is correct |
14 | Correct | 11 ms | 4224 KB | Output is correct |
15 | Correct | 11 ms | 4224 KB | Output is correct |
16 | Correct | 11 ms | 4224 KB | Output is correct |
17 | Correct | 11 ms | 4224 KB | Output is correct |
18 | Correct | 11 ms | 4224 KB | Output is correct |
19 | Correct | 11 ms | 4224 KB | Output is correct |
20 | Correct | 11 ms | 4224 KB | Output is correct |
21 | Correct | 11 ms | 4224 KB | Output is correct |
22 | Correct | 11 ms | 4224 KB | Output is correct |
23 | Correct | 11 ms | 4224 KB | Output is correct |
24 | Correct | 11 ms | 4224 KB | Output is correct |
25 | Correct | 11 ms | 4224 KB | Output is correct |
26 | Correct | 11 ms | 4352 KB | Output is correct |
27 | Correct | 11 ms | 4224 KB | Output is correct |
28 | Correct | 12 ms | 4224 KB | Output is correct |
29 | Correct | 11 ms | 4224 KB | Output is correct |
30 | Correct | 11 ms | 4224 KB | Output is correct |
31 | Correct | 12 ms | 4224 KB | Output is correct |
32 | Correct | 12 ms | 4224 KB | Output is correct |
33 | Correct | 11 ms | 4224 KB | Output is correct |
34 | Correct | 12 ms | 4224 KB | Output is correct |
35 | Incorrect | 12 ms | 4224 KB | Output isn't correct |
36 | Halted | 0 ms | 0 KB | - |