#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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1756 KB |
Output is correct |
2 |
Correct |
0 ms |
1756 KB |
Output is correct |
3 |
Correct |
0 ms |
1756 KB |
Output is correct |
4 |
Correct |
0 ms |
1756 KB |
Output is correct |
5 |
Correct |
0 ms |
1756 KB |
Output is correct |
6 |
Correct |
0 ms |
1756 KB |
Output is correct |
7 |
Correct |
0 ms |
1756 KB |
Output is correct |
8 |
Correct |
1 ms |
1756 KB |
Output is correct |
9 |
Correct |
0 ms |
1756 KB |
Output is correct |
10 |
Correct |
0 ms |
1756 KB |
Output is correct |
11 |
Correct |
1 ms |
1756 KB |
Output is correct |
12 |
Correct |
0 ms |
1756 KB |
Output is correct |
13 |
Correct |
0 ms |
1756 KB |
Output is correct |
14 |
Correct |
0 ms |
1756 KB |
Output is correct |
15 |
Correct |
0 ms |
1756 KB |
Output is correct |
16 |
Correct |
0 ms |
1756 KB |
Output is correct |
17 |
Correct |
0 ms |
1756 KB |
Output is correct |
18 |
Correct |
0 ms |
1756 KB |
Output is correct |
19 |
Correct |
0 ms |
1756 KB |
Output is correct |
20 |
Correct |
0 ms |
1756 KB |
Output is correct |
21 |
Correct |
0 ms |
1756 KB |
Output is correct |
22 |
Correct |
0 ms |
1756 KB |
Output is correct |
23 |
Correct |
0 ms |
1756 KB |
Output is correct |
24 |
Correct |
0 ms |
1756 KB |
Output is correct |
25 |
Correct |
0 ms |
1756 KB |
Output is correct |
26 |
Correct |
0 ms |
1756 KB |
Output is correct |
27 |
Correct |
0 ms |
1756 KB |
Output is correct |
28 |
Correct |
0 ms |
1756 KB |
Output is correct |
29 |
Correct |
0 ms |
1756 KB |
Output is correct |
30 |
Correct |
1 ms |
1756 KB |
Output is correct |
31 |
Correct |
0 ms |
1756 KB |
Output is correct |
32 |
Correct |
0 ms |
1756 KB |
Output is correct |
33 |
Correct |
0 ms |
1756 KB |
Output is correct |
34 |
Correct |
0 ms |
1756 KB |
Output is correct |
35 |
Correct |
0 ms |
1756 KB |
Output is correct |
36 |
Correct |
0 ms |
1756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1756 KB |
Output is correct |
2 |
Correct |
0 ms |
1756 KB |
Output is correct |
3 |
Correct |
0 ms |
1756 KB |
Output is correct |
4 |
Correct |
0 ms |
1756 KB |
Output is correct |
5 |
Correct |
0 ms |
1756 KB |
Output is correct |
6 |
Correct |
0 ms |
1756 KB |
Output is correct |
7 |
Correct |
0 ms |
1756 KB |
Output is correct |
8 |
Correct |
1 ms |
1756 KB |
Output is correct |
9 |
Correct |
0 ms |
1756 KB |
Output is correct |
10 |
Correct |
0 ms |
1756 KB |
Output is correct |
11 |
Correct |
0 ms |
1756 KB |
Output is correct |
12 |
Correct |
0 ms |
1756 KB |
Output is correct |
13 |
Correct |
0 ms |
1756 KB |
Output is correct |
14 |
Correct |
0 ms |
1756 KB |
Output is correct |
15 |
Correct |
0 ms |
1756 KB |
Output is correct |
16 |
Correct |
0 ms |
1756 KB |
Output is correct |
17 |
Correct |
0 ms |
1756 KB |
Output is correct |
18 |
Correct |
0 ms |
1756 KB |
Output is correct |
19 |
Correct |
0 ms |
1756 KB |
Output is correct |
20 |
Correct |
0 ms |
1756 KB |
Output is correct |
21 |
Correct |
0 ms |
1756 KB |
Output is correct |
22 |
Correct |
0 ms |
1756 KB |
Output is correct |
23 |
Correct |
0 ms |
1756 KB |
Output is correct |
24 |
Correct |
0 ms |
1756 KB |
Output is correct |
25 |
Correct |
0 ms |
1756 KB |
Output is correct |
26 |
Correct |
0 ms |
1756 KB |
Output is correct |
27 |
Correct |
0 ms |
1756 KB |
Output is correct |
28 |
Correct |
1 ms |
1756 KB |
Output is correct |
29 |
Correct |
0 ms |
1756 KB |
Output is correct |
30 |
Correct |
3 ms |
1756 KB |
Output is correct |
31 |
Correct |
5 ms |
1756 KB |
Output is correct |
32 |
Correct |
5 ms |
1756 KB |
Output is correct |
33 |
Correct |
5 ms |
1756 KB |
Output is correct |
34 |
Correct |
5 ms |
1756 KB |
Output is correct |
35 |
Correct |
5 ms |
1756 KB |
Output is correct |
36 |
Correct |
2 ms |
1756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1756 KB |
Output is correct |
2 |
Correct |
0 ms |
1756 KB |
Output is correct |
3 |
Correct |
0 ms |
1756 KB |
Output is correct |
4 |
Correct |
0 ms |
1756 KB |
Output is correct |
5 |
Correct |
0 ms |
1756 KB |
Output is correct |
6 |
Correct |
0 ms |
1756 KB |
Output is correct |
7 |
Correct |
0 ms |
1756 KB |
Output is correct |
8 |
Correct |
0 ms |
1756 KB |
Output is correct |
9 |
Correct |
0 ms |
1756 KB |
Output is correct |
10 |
Correct |
0 ms |
1756 KB |
Output is correct |
11 |
Correct |
0 ms |
1756 KB |
Output is correct |
12 |
Correct |
0 ms |
1756 KB |
Output is correct |
13 |
Correct |
0 ms |
1756 KB |
Output is correct |
14 |
Correct |
0 ms |
1756 KB |
Output is correct |
15 |
Correct |
0 ms |
1756 KB |
Output is correct |
16 |
Correct |
0 ms |
1756 KB |
Output is correct |
17 |
Correct |
3 ms |
1756 KB |
Output is correct |
18 |
Correct |
5 ms |
1756 KB |
Output is correct |
19 |
Correct |
5 ms |
1756 KB |
Output is correct |
20 |
Correct |
5 ms |
1756 KB |
Output is correct |
21 |
Correct |
5 ms |
1756 KB |
Output is correct |
22 |
Correct |
5 ms |
1756 KB |
Output is correct |
23 |
Correct |
5 ms |
1756 KB |
Output is correct |
24 |
Correct |
5 ms |
1756 KB |
Output is correct |
25 |
Correct |
11 ms |
1756 KB |
Output is correct |
26 |
Correct |
18 ms |
1756 KB |
Output is correct |
27 |
Correct |
29 ms |
1756 KB |
Output is correct |
28 |
Correct |
38 ms |
1756 KB |
Output is correct |
29 |
Correct |
38 ms |
1756 KB |
Output is correct |
30 |
Correct |
39 ms |
1756 KB |
Output is correct |
31 |
Correct |
38 ms |
1756 KB |
Output is correct |
32 |
Correct |
38 ms |
1756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1756 KB |
Output is correct |
2 |
Correct |
0 ms |
1756 KB |
Output is correct |
3 |
Correct |
0 ms |
1756 KB |
Output is correct |
4 |
Correct |
0 ms |
1756 KB |
Output is correct |
5 |
Correct |
0 ms |
1756 KB |
Output is correct |
6 |
Correct |
0 ms |
1756 KB |
Output is correct |
7 |
Correct |
0 ms |
1756 KB |
Output is correct |
8 |
Correct |
1 ms |
1756 KB |
Output is correct |
9 |
Correct |
0 ms |
1756 KB |
Output is correct |
10 |
Correct |
0 ms |
1756 KB |
Output is correct |
11 |
Correct |
0 ms |
1756 KB |
Output is correct |
12 |
Correct |
0 ms |
1756 KB |
Output is correct |
13 |
Correct |
1 ms |
1756 KB |
Output is correct |
14 |
Correct |
0 ms |
1756 KB |
Output is correct |
15 |
Correct |
0 ms |
1756 KB |
Output is correct |
16 |
Correct |
0 ms |
1756 KB |
Output is correct |
17 |
Correct |
0 ms |
1756 KB |
Output is correct |
18 |
Correct |
0 ms |
1756 KB |
Output is correct |
19 |
Correct |
0 ms |
1756 KB |
Output is correct |
20 |
Correct |
0 ms |
1756 KB |
Output is correct |
21 |
Correct |
0 ms |
1756 KB |
Output is correct |
22 |
Correct |
0 ms |
1756 KB |
Output is correct |
23 |
Correct |
0 ms |
1756 KB |
Output is correct |
24 |
Correct |
0 ms |
1756 KB |
Output is correct |
25 |
Correct |
0 ms |
1756 KB |
Output is correct |
26 |
Correct |
0 ms |
1756 KB |
Output is correct |
27 |
Correct |
0 ms |
1756 KB |
Output is correct |
28 |
Correct |
0 ms |
1756 KB |
Output is correct |
29 |
Correct |
0 ms |
1756 KB |
Output is correct |
30 |
Correct |
0 ms |
1756 KB |
Output is correct |
31 |
Correct |
0 ms |
1756 KB |
Output is correct |
32 |
Correct |
1 ms |
1756 KB |
Output is correct |
33 |
Correct |
0 ms |
1756 KB |
Output is correct |
34 |
Correct |
0 ms |
1756 KB |
Output is correct |
35 |
Correct |
0 ms |
1756 KB |
Output is correct |
36 |
Correct |
0 ms |
1756 KB |
Output is correct |
37 |
Correct |
0 ms |
1756 KB |
Output is correct |
38 |
Correct |
0 ms |
1756 KB |
Output is correct |
39 |
Correct |
0 ms |
1756 KB |
Output is correct |
40 |
Correct |
0 ms |
1756 KB |
Output is correct |
41 |
Correct |
5 ms |
1756 KB |
Output is correct |
42 |
Correct |
5 ms |
1756 KB |
Output is correct |
43 |
Correct |
5 ms |
1756 KB |
Output is correct |
44 |
Correct |
5 ms |
1756 KB |
Output is correct |
45 |
Correct |
5 ms |
1756 KB |
Output is correct |
46 |
Correct |
5 ms |
1756 KB |
Output is correct |
47 |
Correct |
5 ms |
1756 KB |
Output is correct |
48 |
Correct |
11 ms |
1756 KB |
Output is correct |
49 |
Correct |
18 ms |
1756 KB |
Output is correct |
50 |
Correct |
29 ms |
1756 KB |
Output is correct |
51 |
Correct |
39 ms |
1756 KB |
Output is correct |
52 |
Correct |
38 ms |
1756 KB |
Output is correct |
53 |
Correct |
41 ms |
1756 KB |
Output is correct |
54 |
Correct |
38 ms |
1756 KB |
Output is correct |
55 |
Correct |
38 ms |
1756 KB |
Output is correct |
56 |
Correct |
4 ms |
1756 KB |
Output is correct |
57 |
Correct |
13 ms |
1756 KB |
Output is correct |
58 |
Correct |
20 ms |
1756 KB |
Output is correct |
59 |
Correct |
26 ms |
1756 KB |
Output is correct |
60 |
Correct |
25 ms |
1756 KB |
Output is correct |
61 |
Correct |
26 ms |
1756 KB |
Output is correct |
62 |
Correct |
23 ms |
1756 KB |
Output is correct |
63 |
Correct |
26 ms |
1756 KB |
Output is correct |
64 |
Correct |
29 ms |
1756 KB |
Output is correct |
65 |
Correct |
4 ms |
1756 KB |
Output is correct |
66 |
Correct |
8 ms |
1756 KB |
Output is correct |
67 |
Correct |
10 ms |
1756 KB |
Output is correct |
68 |
Correct |
16 ms |
1756 KB |
Output is correct |
69 |
Correct |
25 ms |
1756 KB |
Output is correct |
70 |
Correct |
25 ms |
1756 KB |
Output is correct |
71 |
Correct |
28 ms |
1756 KB |
Output is correct |
72 |
Correct |
27 ms |
1756 KB |
Output is correct |
73 |
Correct |
26 ms |
1756 KB |
Output is correct |
74 |
Correct |
26 ms |
1756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1756 KB |
Output is correct |
2 |
Correct |
0 ms |
1756 KB |
Output is correct |
3 |
Correct |
0 ms |
1756 KB |
Output is correct |
4 |
Correct |
0 ms |
1756 KB |
Output is correct |
5 |
Correct |
0 ms |
1756 KB |
Output is correct |
6 |
Correct |
0 ms |
1756 KB |
Output is correct |
7 |
Correct |
0 ms |
1756 KB |
Output is correct |
8 |
Correct |
0 ms |
1756 KB |
Output is correct |
9 |
Correct |
0 ms |
1756 KB |
Output is correct |
10 |
Correct |
0 ms |
1756 KB |
Output is correct |
11 |
Correct |
0 ms |
1756 KB |
Output is correct |
12 |
Correct |
0 ms |
1756 KB |
Output is correct |
13 |
Correct |
0 ms |
1756 KB |
Output is correct |
14 |
Correct |
0 ms |
1756 KB |
Output is correct |
15 |
Correct |
0 ms |
1756 KB |
Output is correct |
16 |
Correct |
0 ms |
1756 KB |
Output is correct |
17 |
Correct |
0 ms |
1756 KB |
Output is correct |
18 |
Correct |
1 ms |
1756 KB |
Output is correct |
19 |
Correct |
0 ms |
1756 KB |
Output is correct |
20 |
Correct |
0 ms |
1756 KB |
Output is correct |
21 |
Correct |
0 ms |
1756 KB |
Output is correct |
22 |
Correct |
0 ms |
1756 KB |
Output is correct |
23 |
Correct |
0 ms |
1756 KB |
Output is correct |
24 |
Correct |
0 ms |
1756 KB |
Output is correct |
25 |
Correct |
0 ms |
1756 KB |
Output is correct |
26 |
Correct |
2 ms |
1756 KB |
Output is correct |
27 |
Correct |
0 ms |
1756 KB |
Output is correct |
28 |
Correct |
5 ms |
1756 KB |
Output is correct |
29 |
Correct |
5 ms |
1756 KB |
Output is correct |
30 |
Correct |
5 ms |
1756 KB |
Output is correct |
31 |
Correct |
5 ms |
1756 KB |
Output is correct |
32 |
Correct |
5 ms |
1756 KB |
Output is correct |
33 |
Correct |
5 ms |
1756 KB |
Output is correct |
34 |
Correct |
5 ms |
1756 KB |
Output is correct |
35 |
Correct |
7 ms |
1756 KB |
Output is correct |
36 |
Correct |
18 ms |
1756 KB |
Output is correct |
37 |
Correct |
29 ms |
1756 KB |
Output is correct |
38 |
Correct |
38 ms |
1756 KB |
Output is correct |
39 |
Correct |
38 ms |
1756 KB |
Output is correct |
40 |
Correct |
40 ms |
1756 KB |
Output is correct |
41 |
Correct |
38 ms |
1756 KB |
Output is correct |
42 |
Correct |
38 ms |
1756 KB |
Output is correct |
43 |
Correct |
4 ms |
1756 KB |
Output is correct |
44 |
Correct |
13 ms |
1756 KB |
Output is correct |
45 |
Correct |
20 ms |
1756 KB |
Output is correct |
46 |
Correct |
26 ms |
1756 KB |
Output is correct |
47 |
Correct |
22 ms |
1756 KB |
Output is correct |
48 |
Correct |
26 ms |
1756 KB |
Output is correct |
49 |
Correct |
27 ms |
1756 KB |
Output is correct |
50 |
Correct |
27 ms |
1756 KB |
Output is correct |
51 |
Correct |
0 ms |
1756 KB |
Output is correct |
52 |
Correct |
10 ms |
1756 KB |
Output is correct |
53 |
Correct |
16 ms |
1756 KB |
Output is correct |
54 |
Correct |
31 ms |
1756 KB |
Output is correct |
55 |
Correct |
29 ms |
1756 KB |
Output is correct |
56 |
Correct |
103 ms |
1756 KB |
Output is correct |
57 |
Correct |
102 ms |
1756 KB |
Output is correct |
58 |
Correct |
92 ms |
1756 KB |
Output is correct |
59 |
Correct |
96 ms |
1756 KB |
Output is correct |
60 |
Correct |
109 ms |
1756 KB |
Output is correct |
61 |
Correct |
0 ms |
1756 KB |
Output is correct |
62 |
Correct |
16 ms |
1756 KB |
Output is correct |
63 |
Correct |
32 ms |
1756 KB |
Output is correct |
64 |
Correct |
27 ms |
1756 KB |
Output is correct |
65 |
Correct |
52 ms |
1756 KB |
Output is correct |
66 |
Correct |
77 ms |
1756 KB |
Output is correct |
67 |
Correct |
102 ms |
1756 KB |
Output is correct |
68 |
Correct |
106 ms |
1756 KB |
Output is correct |
69 |
Correct |
98 ms |
1756 KB |
Output is correct |