# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44061 | 2018-03-29T13:18:09 Z | zadrga | Bali Sculptures (APIO15_sculpture) | C++14 | 402 ms | 36560 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fi first #define se second #define INF (1LL << 55) #define MOD (1000 * 1000 * 1000 + 7) #define maxn 2111 typedef long long ll; typedef long double ld; int n, a, b; ll pre[maxn], arr[maxn]; ll dp2[maxn][maxn], dp3[maxn]; ll meja; bool fun2(int x, int st){ if(x == n && a <= st && st <= b) return 1; if(x == n) return 0; ll &cur = dp2[x][st]; if(cur != -1) return cur; cur = 0; for(int i = x; i < n; i++){ if( ((~meja) & (pre[i] - pre[x - 1])) == 0){ cur |= fun2(i + 1, st + 1); } } return cur; } void solve2(){ meja = (1LL << 50) - 1; for(int i = 49; i >= 0; i--){ memset(dp2, -1, sizeof(dp2)); meja ^= (1LL << i); if(!fun2(0, 0)){ meja ^= (1LL << i); } } printf("%lld\n", meja); } ll fun3(int x){ if(x == n) return 0; ll &cur = dp3[x]; if(cur != -1) return cur; cur = INF; for(int i = x; i < n; i++){ if( ((~meja) & (pre[i] - pre[x - 1])) == 0){ cur = min(cur, 1LL + fun3(i + 1)); } } return cur; } void solve3(){ meja = (1LL << 50) - 1; for(int i = 49; i >= 0; i--){ memset(dp3, -1, sizeof(dp3)); meja ^= (1LL << i); if(fun3(0) > b){ meja ^= (1LL << i); } } printf("%lld\n", meja); } int main(){ scanf("%d%d%d", &n, &a, &b); for(int i = 0; i < n; i++){ scanf("%lld", arr + i); if(i) pre[i] = pre[i - 1]; pre[i] += arr[i]; } if(a != 1) solve2(); else solve3(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 488 KB | Output is correct |
4 | Correct | 2 ms | 488 KB | Output is correct |
5 | Correct | 2 ms | 488 KB | Output is correct |
6 | Correct | 2 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 704 KB | Output is correct |
8 | Correct | 2 ms | 704 KB | Output is correct |
9 | Correct | 2 ms | 704 KB | Output is correct |
10 | Correct | 2 ms | 704 KB | Output is correct |
11 | Correct | 2 ms | 704 KB | Output is correct |
12 | Correct | 2 ms | 836 KB | Output is correct |
13 | Correct | 2 ms | 836 KB | Output is correct |
14 | Correct | 344 ms | 35548 KB | Output is correct |
15 | Correct | 359 ms | 35660 KB | Output is correct |
16 | Correct | 372 ms | 35660 KB | Output is correct |
17 | Correct | 360 ms | 35668 KB | Output is correct |
18 | Correct | 346 ms | 35668 KB | Output is correct |
19 | Correct | 354 ms | 35676 KB | Output is correct |
20 | Correct | 375 ms | 35676 KB | Output is correct |
21 | Correct | 343 ms | 35684 KB | Output is correct |
22 | Correct | 345 ms | 35700 KB | Output is correct |
23 | Correct | 388 ms | 35708 KB | Output is correct |
24 | Correct | 386 ms | 35716 KB | Output is correct |
25 | Correct | 353 ms | 35720 KB | Output is correct |
26 | Correct | 355 ms | 35720 KB | Output is correct |
27 | Correct | 2 ms | 35720 KB | Output is correct |
28 | Correct | 2 ms | 35720 KB | Output is correct |
29 | Correct | 2 ms | 35720 KB | Output is correct |
30 | Correct | 2 ms | 35720 KB | Output is correct |
31 | Correct | 2 ms | 35720 KB | Output is correct |
32 | Correct | 3 ms | 35720 KB | Output is correct |
33 | Correct | 2 ms | 35720 KB | Output is correct |
34 | Correct | 2 ms | 35720 KB | Output is correct |
35 | Correct | 2 ms | 35720 KB | Output is correct |
36 | Correct | 2 ms | 35720 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 35720 KB | Output is correct |
2 | Correct | 2 ms | 35720 KB | Output is correct |
3 | Correct | 2 ms | 35720 KB | Output is correct |
4 | Correct | 2 ms | 35720 KB | Output is correct |
5 | Correct | 2 ms | 35720 KB | Output is correct |
6 | Correct | 2 ms | 35720 KB | Output is correct |
7 | Correct | 2 ms | 35720 KB | Output is correct |
8 | Correct | 2 ms | 35720 KB | Output is correct |
9 | Correct | 2 ms | 35720 KB | Output is correct |
10 | Correct | 2 ms | 35720 KB | Output is correct |
11 | Correct | 2 ms | 35720 KB | Output is correct |
12 | Correct | 2 ms | 35720 KB | Output is correct |
13 | Correct | 2 ms | 35720 KB | Output is correct |
14 | Correct | 387 ms | 35820 KB | Output is correct |
15 | Correct | 340 ms | 35820 KB | Output is correct |
16 | Correct | 370 ms | 35820 KB | Output is correct |
17 | Correct | 334 ms | 35832 KB | Output is correct |
18 | Correct | 355 ms | 35832 KB | Output is correct |
19 | Correct | 372 ms | 35840 KB | Output is correct |
20 | Correct | 335 ms | 35840 KB | Output is correct |
21 | Correct | 363 ms | 35848 KB | Output is correct |
22 | Correct | 371 ms | 35848 KB | Output is correct |
23 | Correct | 345 ms | 35848 KB | Output is correct |
24 | Correct | 395 ms | 35856 KB | Output is correct |
25 | Correct | 377 ms | 35860 KB | Output is correct |
26 | Correct | 349 ms | 35872 KB | Output is correct |
27 | Correct | 2 ms | 35872 KB | Output is correct |
28 | Correct | 2 ms | 35872 KB | Output is correct |
29 | Correct | 2 ms | 35872 KB | Output is correct |
30 | Correct | 2 ms | 35872 KB | Output is correct |
31 | Correct | 2 ms | 35872 KB | Output is correct |
32 | Correct | 2 ms | 35872 KB | Output is correct |
33 | Correct | 2 ms | 35872 KB | Output is correct |
34 | Correct | 2 ms | 35872 KB | Output is correct |
35 | Correct | 2 ms | 35872 KB | Output is correct |
36 | Correct | 3 ms | 35872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 35872 KB | Output is correct |
2 | Correct | 2 ms | 35872 KB | Output is correct |
3 | Correct | 2 ms | 35872 KB | Output is correct |
4 | Correct | 2 ms | 35872 KB | Output is correct |
5 | Correct | 2 ms | 35872 KB | Output is correct |
6 | Correct | 2 ms | 35872 KB | Output is correct |
7 | Correct | 2 ms | 35872 KB | Output is correct |
8 | Correct | 2 ms | 35872 KB | Output is correct |
9 | Correct | 2 ms | 35872 KB | Output is correct |
10 | Correct | 2 ms | 35872 KB | Output is correct |
11 | Correct | 2 ms | 35872 KB | Output is correct |
12 | Correct | 2 ms | 35872 KB | Output is correct |
13 | Correct | 2 ms | 35872 KB | Output is correct |
14 | Correct | 2 ms | 35872 KB | Output is correct |
15 | Correct | 2 ms | 35872 KB | Output is correct |
16 | Correct | 2 ms | 35872 KB | Output is correct |
17 | Correct | 2 ms | 35872 KB | Output is correct |
18 | Correct | 2 ms | 35872 KB | Output is correct |
19 | Correct | 2 ms | 35872 KB | Output is correct |
20 | Correct | 3 ms | 35872 KB | Output is correct |
21 | Correct | 2 ms | 35872 KB | Output is correct |
22 | Correct | 2 ms | 35872 KB | Output is correct |
23 | Correct | 2 ms | 35872 KB | Output is correct |
24 | Correct | 2 ms | 35872 KB | Output is correct |
25 | Correct | 2 ms | 35872 KB | Output is correct |
26 | Correct | 3 ms | 35872 KB | Output is correct |
27 | Correct | 3 ms | 35872 KB | Output is correct |
28 | Correct | 4 ms | 35872 KB | Output is correct |
29 | Correct | 4 ms | 35872 KB | Output is correct |
30 | Correct | 3 ms | 35872 KB | Output is correct |
31 | Correct | 3 ms | 35872 KB | Output is correct |
32 | Correct | 3 ms | 35872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 35872 KB | Output is correct |
2 | Correct | 2 ms | 35872 KB | Output is correct |
3 | Correct | 2 ms | 35872 KB | Output is correct |
4 | Correct | 2 ms | 35872 KB | Output is correct |
5 | Correct | 2 ms | 35872 KB | Output is correct |
6 | Correct | 2 ms | 35872 KB | Output is correct |
7 | Correct | 2 ms | 35872 KB | Output is correct |
8 | Correct | 2 ms | 35872 KB | Output is correct |
9 | Correct | 2 ms | 35872 KB | Output is correct |
10 | Correct | 2 ms | 35872 KB | Output is correct |
11 | Correct | 3 ms | 35872 KB | Output is correct |
12 | Correct | 2 ms | 35872 KB | Output is correct |
13 | Correct | 2 ms | 35872 KB | Output is correct |
14 | Correct | 339 ms | 36128 KB | Output is correct |
15 | Correct | 360 ms | 36144 KB | Output is correct |
16 | Correct | 361 ms | 36176 KB | Output is correct |
17 | Correct | 341 ms | 36176 KB | Output is correct |
18 | Correct | 356 ms | 36176 KB | Output is correct |
19 | Correct | 384 ms | 36188 KB | Output is correct |
20 | Correct | 357 ms | 36192 KB | Output is correct |
21 | Correct | 366 ms | 36288 KB | Output is correct |
22 | Correct | 370 ms | 36288 KB | Output is correct |
23 | Correct | 340 ms | 36288 KB | Output is correct |
24 | Correct | 342 ms | 36288 KB | Output is correct |
25 | Correct | 344 ms | 36288 KB | Output is correct |
26 | Correct | 333 ms | 36308 KB | Output is correct |
27 | Correct | 2 ms | 36308 KB | Output is correct |
28 | Correct | 2 ms | 36308 KB | Output is correct |
29 | Correct | 2 ms | 36308 KB | Output is correct |
30 | Correct | 2 ms | 36308 KB | Output is correct |
31 | Correct | 2 ms | 36308 KB | Output is correct |
32 | Correct | 2 ms | 36308 KB | Output is correct |
33 | Correct | 2 ms | 36308 KB | Output is correct |
34 | Correct | 3 ms | 36308 KB | Output is correct |
35 | Correct | 2 ms | 36308 KB | Output is correct |
36 | Correct | 2 ms | 36308 KB | Output is correct |
37 | Correct | 2 ms | 36308 KB | Output is correct |
38 | Correct | 2 ms | 36308 KB | Output is correct |
39 | Correct | 2 ms | 36308 KB | Output is correct |
40 | Correct | 2 ms | 36308 KB | Output is correct |
41 | Correct | 2 ms | 36308 KB | Output is correct |
42 | Correct | 2 ms | 36308 KB | Output is correct |
43 | Correct | 2 ms | 36308 KB | Output is correct |
44 | Correct | 2 ms | 36308 KB | Output is correct |
45 | Correct | 2 ms | 36308 KB | Output is correct |
46 | Correct | 2 ms | 36308 KB | Output is correct |
47 | Correct | 2 ms | 36308 KB | Output is correct |
48 | Correct | 3 ms | 36308 KB | Output is correct |
49 | Correct | 3 ms | 36308 KB | Output is correct |
50 | Correct | 3 ms | 36308 KB | Output is correct |
51 | Correct | 3 ms | 36308 KB | Output is correct |
52 | Correct | 3 ms | 36308 KB | Output is correct |
53 | Correct | 3 ms | 36308 KB | Output is correct |
54 | Correct | 3 ms | 36308 KB | Output is correct |
55 | Correct | 3 ms | 36308 KB | Output is correct |
56 | Correct | 2 ms | 36308 KB | Output is correct |
57 | Correct | 2 ms | 36308 KB | Output is correct |
58 | Correct | 3 ms | 36308 KB | Output is correct |
59 | Correct | 3 ms | 36308 KB | Output is correct |
60 | Correct | 2 ms | 36308 KB | Output is correct |
61 | Correct | 2 ms | 36308 KB | Output is correct |
62 | Correct | 3 ms | 36308 KB | Output is correct |
63 | Correct | 3 ms | 36308 KB | Output is correct |
64 | Correct | 402 ms | 36368 KB | Output is correct |
65 | Correct | 341 ms | 36440 KB | Output is correct |
66 | Correct | 338 ms | 36512 KB | Output is correct |
67 | Correct | 346 ms | 36512 KB | Output is correct |
68 | Correct | 359 ms | 36512 KB | Output is correct |
69 | Correct | 365 ms | 36512 KB | Output is correct |
70 | Correct | 351 ms | 36560 KB | Output is correct |
71 | Correct | 359 ms | 36560 KB | Output is correct |
72 | Correct | 361 ms | 36560 KB | Output is correct |
73 | Correct | 364 ms | 36560 KB | Output is correct |
74 | Correct | 370 ms | 36560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 36560 KB | Output is correct |
2 | Correct | 2 ms | 36560 KB | Output is correct |
3 | Correct | 2 ms | 36560 KB | Output is correct |
4 | Correct | 2 ms | 36560 KB | Output is correct |
5 | Correct | 2 ms | 36560 KB | Output is correct |
6 | Correct | 2 ms | 36560 KB | Output is correct |
7 | Correct | 2 ms | 36560 KB | Output is correct |
8 | Correct | 2 ms | 36560 KB | Output is correct |
9 | Correct | 3 ms | 36560 KB | Output is correct |
10 | Correct | 2 ms | 36560 KB | Output is correct |
11 | Correct | 2 ms | 36560 KB | Output is correct |
12 | Correct | 2 ms | 36560 KB | Output is correct |
13 | Correct | 2 ms | 36560 KB | Output is correct |
14 | Correct | 2 ms | 36560 KB | Output is correct |
15 | Correct | 2 ms | 36560 KB | Output is correct |
16 | Correct | 2 ms | 36560 KB | Output is correct |
17 | Correct | 2 ms | 36560 KB | Output is correct |
18 | Correct | 2 ms | 36560 KB | Output is correct |
19 | Correct | 2 ms | 36560 KB | Output is correct |
20 | Correct | 2 ms | 36560 KB | Output is correct |
21 | Correct | 2 ms | 36560 KB | Output is correct |
22 | Correct | 2 ms | 36560 KB | Output is correct |
23 | Correct | 2 ms | 36560 KB | Output is correct |
24 | Correct | 2 ms | 36560 KB | Output is correct |
25 | Correct | 2 ms | 36560 KB | Output is correct |
26 | Correct | 2 ms | 36560 KB | Output is correct |
27 | Correct | 2 ms | 36560 KB | Output is correct |
28 | Correct | 2 ms | 36560 KB | Output is correct |
29 | Correct | 3 ms | 36560 KB | Output is correct |
30 | Correct | 2 ms | 36560 KB | Output is correct |
31 | Correct | 2 ms | 36560 KB | Output is correct |
32 | Correct | 2 ms | 36560 KB | Output is correct |
33 | Correct | 4 ms | 36560 KB | Output is correct |
34 | Correct | 2 ms | 36560 KB | Output is correct |
35 | Correct | 2 ms | 36560 KB | Output is correct |
36 | Correct | 3 ms | 36560 KB | Output is correct |
37 | Correct | 3 ms | 36560 KB | Output is correct |
38 | Correct | 3 ms | 36560 KB | Output is correct |
39 | Correct | 3 ms | 36560 KB | Output is correct |
40 | Correct | 4 ms | 36560 KB | Output is correct |
41 | Correct | 4 ms | 36560 KB | Output is correct |
42 | Correct | 3 ms | 36560 KB | Output is correct |
43 | Correct | 2 ms | 36560 KB | Output is correct |
44 | Correct | 3 ms | 36560 KB | Output is correct |
45 | Correct | 3 ms | 36560 KB | Output is correct |
46 | Correct | 3 ms | 36560 KB | Output is correct |
47 | Correct | 3 ms | 36560 KB | Output is correct |
48 | Correct | 3 ms | 36560 KB | Output is correct |
49 | Correct | 3 ms | 36560 KB | Output is correct |
50 | Correct | 3 ms | 36560 KB | Output is correct |
51 | Correct | 4 ms | 36560 KB | Output is correct |
52 | Correct | 21 ms | 36560 KB | Output is correct |
53 | Correct | 28 ms | 36560 KB | Output is correct |
54 | Correct | 69 ms | 36560 KB | Output is correct |
55 | Correct | 56 ms | 36560 KB | Output is correct |
56 | Correct | 228 ms | 36560 KB | Output is correct |
57 | Correct | 172 ms | 36560 KB | Output is correct |
58 | Correct | 182 ms | 36560 KB | Output is correct |
59 | Correct | 200 ms | 36560 KB | Output is correct |
60 | Correct | 184 ms | 36560 KB | Output is correct |
61 | Correct | 3 ms | 36560 KB | Output is correct |
62 | Correct | 35 ms | 36560 KB | Output is correct |
63 | Correct | 66 ms | 36560 KB | Output is correct |
64 | Correct | 46 ms | 36560 KB | Output is correct |
65 | Correct | 87 ms | 36560 KB | Output is correct |
66 | Correct | 128 ms | 36560 KB | Output is correct |
67 | Correct | 170 ms | 36560 KB | Output is correct |
68 | Correct | 238 ms | 36560 KB | Output is correct |
69 | Correct | 166 ms | 36560 KB | Output is correct |