# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
30877 | 2017-07-29T18:59:46 Z | Navick | Bali Sculptures (APIO15_sculpture) | C++14 | 96 ms | 2052 KB |
#include <bits/stdc++.h> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <time.h> #include <limits.h> using namespace std; typedef long long ll; typedef double lf; const int N_ = 2050; int N, A, B; ll S[N_]; ll ans; bool tb1[105][105]; void solve1() { ans = 0; ll cur = 0; for(int b = 41; b >= 0; b--) { ll t = cur | (1ll << b); tb1[0][0] = true; for(int i = 1; i <= N; i++) for(int x = 1; x <= i; x++) { tb1[i][x] = false; for(int j = 0; j < i; j++) { ll s = S[i] - S[j]; if((s & t) == 0) tb1[i][x] |= tb1[j][x - 1]; } } bool good = false; for(int x = A; x <= B; x++) good |= tb1[N][x]; if(good) { cur = t; }else { ans += 1ll << b; } } } int tb2[N_]; void solve2() { ans = 0; ll cur = 0; for(int b = 41; b >= 0; b--) { ll t = cur | (1ll << b); for(int i = 1; i <= N; i++) { tb2[i] = (int)1e6; for(int j = 0; j < i; j++) { ll s = S[i] - S[j]; if((s & t) == 0) tb2[i] = min(tb2[i], tb2[j] + 1); } } //printf("%lld %lld %d\n", ans, 1ll<<b, tb2[N]); if(tb2[N] <= B) { cur = t; }else { ans += 1ll << b; } } } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); scanf("%d%d%d", &N, &A, &B); for(int i = 1; i <= N; i++) { int x; scanf("%d", &x); S[i] = S[i-1] + x; } if(N <= 100) { solve1(); }else { solve2(); } printf("%lld\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2052 KB | Output is correct |
2 | Correct | 0 ms | 2052 KB | Output is correct |
3 | Correct | 0 ms | 2052 KB | Output is correct |
4 | Correct | 0 ms | 2052 KB | Output is correct |
5 | Correct | 0 ms | 2052 KB | Output is correct |
6 | Correct | 0 ms | 2052 KB | Output is correct |
7 | Correct | 0 ms | 2052 KB | Output is correct |
8 | Correct | 0 ms | 2052 KB | Output is correct |
9 | Correct | 0 ms | 2052 KB | Output is correct |
10 | Correct | 0 ms | 2052 KB | Output is correct |
11 | Correct | 0 ms | 2052 KB | Output is correct |
12 | Correct | 0 ms | 2052 KB | Output is correct |
13 | Correct | 0 ms | 2052 KB | Output is correct |
14 | Correct | 0 ms | 2052 KB | Output is correct |
15 | Correct | 0 ms | 2052 KB | Output is correct |
16 | Correct | 0 ms | 2052 KB | Output is correct |
17 | Correct | 0 ms | 2052 KB | Output is correct |
18 | Correct | 0 ms | 2052 KB | Output is correct |
19 | Correct | 0 ms | 2052 KB | Output is correct |
20 | Correct | 0 ms | 2052 KB | Output is correct |
21 | Correct | 0 ms | 2052 KB | Output is correct |
22 | Correct | 0 ms | 2052 KB | Output is correct |
23 | Correct | 0 ms | 2052 KB | Output is correct |
24 | Correct | 0 ms | 2052 KB | Output is correct |
25 | Correct | 0 ms | 2052 KB | Output is correct |
26 | Correct | 0 ms | 2052 KB | Output is correct |
27 | Correct | 0 ms | 2052 KB | Output is correct |
28 | Correct | 0 ms | 2052 KB | Output is correct |
29 | Correct | 0 ms | 2052 KB | Output is correct |
30 | Correct | 0 ms | 2052 KB | Output is correct |
31 | Correct | 0 ms | 2052 KB | Output is correct |
32 | Correct | 0 ms | 2052 KB | Output is correct |
33 | Correct | 0 ms | 2052 KB | Output is correct |
34 | Correct | 0 ms | 2052 KB | Output is correct |
35 | Correct | 0 ms | 2052 KB | Output is correct |
36 | Correct | 0 ms | 2052 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2052 KB | Output is correct |
2 | Correct | 0 ms | 2052 KB | Output is correct |
3 | Correct | 0 ms | 2052 KB | Output is correct |
4 | Correct | 0 ms | 2052 KB | Output is correct |
5 | Correct | 0 ms | 2052 KB | Output is correct |
6 | Correct | 0 ms | 2052 KB | Output is correct |
7 | Correct | 0 ms | 2052 KB | Output is correct |
8 | Correct | 0 ms | 2052 KB | Output is correct |
9 | Correct | 0 ms | 2052 KB | Output is correct |
10 | Correct | 0 ms | 2052 KB | Output is correct |
11 | Correct | 0 ms | 2052 KB | Output is correct |
12 | Correct | 0 ms | 2052 KB | Output is correct |
13 | Correct | 0 ms | 2052 KB | Output is correct |
14 | Correct | 0 ms | 2052 KB | Output is correct |
15 | Correct | 0 ms | 2052 KB | Output is correct |
16 | Correct | 0 ms | 2052 KB | Output is correct |
17 | Correct | 0 ms | 2052 KB | Output is correct |
18 | Correct | 0 ms | 2052 KB | Output is correct |
19 | Correct | 0 ms | 2052 KB | Output is correct |
20 | Correct | 0 ms | 2052 KB | Output is correct |
21 | Correct | 0 ms | 2052 KB | Output is correct |
22 | Correct | 0 ms | 2052 KB | Output is correct |
23 | Correct | 0 ms | 2052 KB | Output is correct |
24 | Correct | 0 ms | 2052 KB | Output is correct |
25 | Correct | 0 ms | 2052 KB | Output is correct |
26 | Correct | 0 ms | 2052 KB | Output is correct |
27 | Correct | 0 ms | 2052 KB | Output is correct |
28 | Correct | 0 ms | 2052 KB | Output is correct |
29 | Correct | 0 ms | 2052 KB | Output is correct |
30 | Correct | 0 ms | 2052 KB | Output is correct |
31 | Correct | 3 ms | 2052 KB | Output is correct |
32 | Correct | 3 ms | 2052 KB | Output is correct |
33 | Correct | 3 ms | 2052 KB | Output is correct |
34 | Correct | 3 ms | 2052 KB | Output is correct |
35 | Correct | 3 ms | 2052 KB | Output is correct |
36 | Correct | 3 ms | 2052 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2052 KB | Output is correct |
2 | Correct | 0 ms | 2052 KB | Output is correct |
3 | Correct | 0 ms | 2052 KB | Output is correct |
4 | Correct | 0 ms | 2052 KB | Output is correct |
5 | Correct | 0 ms | 2052 KB | Output is correct |
6 | Correct | 0 ms | 2052 KB | Output is correct |
7 | Correct | 0 ms | 2052 KB | Output is correct |
8 | Correct | 0 ms | 2052 KB | Output is correct |
9 | Correct | 0 ms | 2052 KB | Output is correct |
10 | Correct | 0 ms | 2052 KB | Output is correct |
11 | Correct | 0 ms | 2052 KB | Output is correct |
12 | Correct | 0 ms | 2052 KB | Output is correct |
13 | Correct | 0 ms | 2052 KB | Output is correct |
14 | Correct | 0 ms | 2052 KB | Output is correct |
15 | Correct | 0 ms | 2052 KB | Output is correct |
16 | Correct | 0 ms | 2052 KB | Output is correct |
17 | Correct | 0 ms | 2052 KB | Output is correct |
18 | Correct | 3 ms | 2052 KB | Output is correct |
19 | Correct | 3 ms | 2052 KB | Output is correct |
20 | Correct | 3 ms | 2052 KB | Output is correct |
21 | Correct | 3 ms | 2052 KB | Output is correct |
22 | Correct | 3 ms | 2052 KB | Output is correct |
23 | Correct | 3 ms | 2052 KB | Output is correct |
24 | Correct | 3 ms | 2052 KB | Output is correct |
25 | Correct | 6 ms | 2052 KB | Output is correct |
26 | Correct | 13 ms | 2052 KB | Output is correct |
27 | Correct | 23 ms | 2052 KB | Output is correct |
28 | Correct | 29 ms | 2052 KB | Output is correct |
29 | Correct | 29 ms | 2052 KB | Output is correct |
30 | Correct | 29 ms | 2052 KB | Output is correct |
31 | Correct | 29 ms | 2052 KB | Output is correct |
32 | Correct | 29 ms | 2052 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2052 KB | Output is correct |
2 | Correct | 0 ms | 2052 KB | Output is correct |
3 | Correct | 0 ms | 2052 KB | Output is correct |
4 | Correct | 0 ms | 2052 KB | Output is correct |
5 | Correct | 0 ms | 2052 KB | Output is correct |
6 | Correct | 0 ms | 2052 KB | Output is correct |
7 | Correct | 0 ms | 2052 KB | Output is correct |
8 | Correct | 0 ms | 2052 KB | Output is correct |
9 | Correct | 0 ms | 2052 KB | Output is correct |
10 | Correct | 0 ms | 2052 KB | Output is correct |
11 | Correct | 0 ms | 2052 KB | Output is correct |
12 | Correct | 0 ms | 2052 KB | Output is correct |
13 | Correct | 0 ms | 2052 KB | Output is correct |
14 | Correct | 0 ms | 2052 KB | Output is correct |
15 | Correct | 0 ms | 2052 KB | Output is correct |
16 | Correct | 0 ms | 2052 KB | Output is correct |
17 | Correct | 0 ms | 2052 KB | Output is correct |
18 | Correct | 0 ms | 2052 KB | Output is correct |
19 | Correct | 0 ms | 2052 KB | Output is correct |
20 | Correct | 0 ms | 2052 KB | Output is correct |
21 | Correct | 0 ms | 2052 KB | Output is correct |
22 | Correct | 0 ms | 2052 KB | Output is correct |
23 | Correct | 0 ms | 2052 KB | Output is correct |
24 | Correct | 0 ms | 2052 KB | Output is correct |
25 | Correct | 0 ms | 2052 KB | Output is correct |
26 | Correct | 0 ms | 2052 KB | Output is correct |
27 | Correct | 0 ms | 2052 KB | Output is correct |
28 | Correct | 0 ms | 2052 KB | Output is correct |
29 | Correct | 0 ms | 2052 KB | Output is correct |
30 | Correct | 0 ms | 2052 KB | Output is correct |
31 | Correct | 0 ms | 2052 KB | Output is correct |
32 | Correct | 0 ms | 2052 KB | Output is correct |
33 | Correct | 0 ms | 2052 KB | Output is correct |
34 | Correct | 0 ms | 2052 KB | Output is correct |
35 | Correct | 0 ms | 2052 KB | Output is correct |
36 | Correct | 0 ms | 2052 KB | Output is correct |
37 | Correct | 0 ms | 2052 KB | Output is correct |
38 | Correct | 0 ms | 2052 KB | Output is correct |
39 | Correct | 0 ms | 2052 KB | Output is correct |
40 | Correct | 3 ms | 2052 KB | Output is correct |
41 | Correct | 3 ms | 2052 KB | Output is correct |
42 | Correct | 3 ms | 2052 KB | Output is correct |
43 | Correct | 3 ms | 2052 KB | Output is correct |
44 | Correct | 3 ms | 2052 KB | Output is correct |
45 | Correct | 3 ms | 2052 KB | Output is correct |
46 | Correct | 3 ms | 2052 KB | Output is correct |
47 | Correct | 3 ms | 2052 KB | Output is correct |
48 | Correct | 6 ms | 2052 KB | Output is correct |
49 | Correct | 13 ms | 2052 KB | Output is correct |
50 | Correct | 23 ms | 2052 KB | Output is correct |
51 | Correct | 29 ms | 2052 KB | Output is correct |
52 | Correct | 33 ms | 2052 KB | Output is correct |
53 | Correct | 29 ms | 2052 KB | Output is correct |
54 | Correct | 29 ms | 2052 KB | Output is correct |
55 | Correct | 33 ms | 2052 KB | Output is correct |
56 | Correct | 3 ms | 2052 KB | Output is correct |
57 | Correct | 9 ms | 2052 KB | Output is correct |
58 | Correct | 13 ms | 2052 KB | Output is correct |
59 | Correct | 16 ms | 2052 KB | Output is correct |
60 | Correct | 16 ms | 2052 KB | Output is correct |
61 | Correct | 19 ms | 2052 KB | Output is correct |
62 | Correct | 19 ms | 2052 KB | Output is correct |
63 | Correct | 19 ms | 2052 KB | Output is correct |
64 | Correct | 23 ms | 2052 KB | Output is correct |
65 | Correct | 0 ms | 2052 KB | Output is correct |
66 | Correct | 3 ms | 2052 KB | Output is correct |
67 | Correct | 9 ms | 2052 KB | Output is correct |
68 | Correct | 13 ms | 2052 KB | Output is correct |
69 | Correct | 26 ms | 2052 KB | Output is correct |
70 | Correct | 29 ms | 2052 KB | Output is correct |
71 | Correct | 19 ms | 2052 KB | Output is correct |
72 | Correct | 19 ms | 2052 KB | Output is correct |
73 | Correct | 19 ms | 2052 KB | Output is correct |
74 | Correct | 19 ms | 2052 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2052 KB | Output is correct |
2 | Correct | 0 ms | 2052 KB | Output is correct |
3 | Correct | 0 ms | 2052 KB | Output is correct |
4 | Correct | 0 ms | 2052 KB | Output is correct |
5 | Correct | 0 ms | 2052 KB | Output is correct |
6 | Correct | 0 ms | 2052 KB | Output is correct |
7 | Correct | 0 ms | 2052 KB | Output is correct |
8 | Correct | 0 ms | 2052 KB | Output is correct |
9 | Correct | 0 ms | 2052 KB | Output is correct |
10 | Correct | 0 ms | 2052 KB | Output is correct |
11 | Correct | 0 ms | 2052 KB | Output is correct |
12 | Correct | 0 ms | 2052 KB | Output is correct |
13 | Correct | 0 ms | 2052 KB | Output is correct |
14 | Correct | 0 ms | 2052 KB | Output is correct |
15 | Correct | 0 ms | 2052 KB | Output is correct |
16 | Correct | 0 ms | 2052 KB | Output is correct |
17 | Correct | 0 ms | 2052 KB | Output is correct |
18 | Correct | 0 ms | 2052 KB | Output is correct |
19 | Correct | 0 ms | 2052 KB | Output is correct |
20 | Correct | 0 ms | 2052 KB | Output is correct |
21 | Correct | 0 ms | 2052 KB | Output is correct |
22 | Correct | 0 ms | 2052 KB | Output is correct |
23 | Correct | 0 ms | 2052 KB | Output is correct |
24 | Correct | 0 ms | 2052 KB | Output is correct |
25 | Correct | 0 ms | 2052 KB | Output is correct |
26 | Correct | 0 ms | 2052 KB | Output is correct |
27 | Correct | 0 ms | 2052 KB | Output is correct |
28 | Correct | 3 ms | 2052 KB | Output is correct |
29 | Correct | 3 ms | 2052 KB | Output is correct |
30 | Correct | 3 ms | 2052 KB | Output is correct |
31 | Correct | 3 ms | 2052 KB | Output is correct |
32 | Correct | 3 ms | 2052 KB | Output is correct |
33 | Correct | 3 ms | 2052 KB | Output is correct |
34 | Correct | 3 ms | 2052 KB | Output is correct |
35 | Correct | 6 ms | 2052 KB | Output is correct |
36 | Correct | 13 ms | 2052 KB | Output is correct |
37 | Correct | 23 ms | 2052 KB | Output is correct |
38 | Correct | 33 ms | 2052 KB | Output is correct |
39 | Correct | 29 ms | 2052 KB | Output is correct |
40 | Correct | 33 ms | 2052 KB | Output is correct |
41 | Correct | 29 ms | 2052 KB | Output is correct |
42 | Correct | 29 ms | 2052 KB | Output is correct |
43 | Correct | 3 ms | 2052 KB | Output is correct |
44 | Correct | 9 ms | 2052 KB | Output is correct |
45 | Correct | 13 ms | 2052 KB | Output is correct |
46 | Correct | 19 ms | 2052 KB | Output is correct |
47 | Correct | 16 ms | 2052 KB | Output is correct |
48 | Correct | 19 ms | 2052 KB | Output is correct |
49 | Correct | 19 ms | 2052 KB | Output is correct |
50 | Correct | 23 ms | 2052 KB | Output is correct |
51 | Correct | 0 ms | 2052 KB | Output is correct |
52 | Correct | 9 ms | 2052 KB | Output is correct |
53 | Correct | 13 ms | 2052 KB | Output is correct |
54 | Correct | 26 ms | 2052 KB | Output is correct |
55 | Correct | 26 ms | 2052 KB | Output is correct |
56 | Correct | 96 ms | 2052 KB | Output is correct |
57 | Correct | 93 ms | 2052 KB | Output is correct |
58 | Correct | 89 ms | 2052 KB | Output is correct |
59 | Correct | 89 ms | 2052 KB | Output is correct |
60 | Correct | 96 ms | 2052 KB | Output is correct |
61 | Correct | 0 ms | 2052 KB | Output is correct |
62 | Correct | 13 ms | 2052 KB | Output is correct |
63 | Correct | 26 ms | 2052 KB | Output is correct |
64 | Correct | 23 ms | 2052 KB | Output is correct |
65 | Correct | 46 ms | 2052 KB | Output is correct |
66 | Correct | 69 ms | 2052 KB | Output is correct |
67 | Correct | 96 ms | 2052 KB | Output is correct |
68 | Correct | 93 ms | 2052 KB | Output is correct |
69 | Correct | 89 ms | 2052 KB | Output is correct |