#include <bitset>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int bits = 41;
int main() {
int N, A, B;
cin >> N >> A >> B;
vector<long long> V(N), S(N + 1);
for(int i = 0; i < N; ++i) {
cin >> V[i];
S[i + 1] = S[i] + V[i];
}
long long cur = 0;
for(int i = bits - 1; i >= 0; --i) {
vector<bitset<2001> > dp(N + 1);
dp[0][0] = 1;
for(int j = 1; j <= N; ++j) {
for(int k = 0; k < j; ++k) {
long long X = S[j] - S[k];
if((X | cur | ((1LL << i) - 1)) == (cur | ((1LL << i) - 1))) {
dp[j] |= dp[k] << 1;
}
}
}
bool ok = false;
for(int j = A; j <= B; ++j) {
if(dp[N][j]) ok = true;
}
if(!ok) cur |= 1LL << i;
}
cout << cur << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
3 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
2 ms |
256 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
256 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
256 KB |
Output is correct |
33 |
Correct |
2 ms |
256 KB |
Output is correct |
34 |
Correct |
3 ms |
384 KB |
Output is correct |
35 |
Correct |
2 ms |
256 KB |
Output is correct |
36 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 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 |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 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 |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
3 ms |
256 KB |
Output is correct |
22 |
Correct |
4 ms |
256 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
256 KB |
Output is correct |
25 |
Correct |
3 ms |
256 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
256 KB |
Output is correct |
28 |
Correct |
3 ms |
256 KB |
Output is correct |
29 |
Correct |
4 ms |
384 KB |
Output is correct |
30 |
Correct |
4 ms |
256 KB |
Output is correct |
31 |
Correct |
4 ms |
256 KB |
Output is correct |
32 |
Correct |
5 ms |
256 KB |
Output is correct |
33 |
Correct |
5 ms |
460 KB |
Output is correct |
34 |
Correct |
5 ms |
384 KB |
Output is correct |
35 |
Correct |
7 ms |
384 KB |
Output is correct |
36 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
3 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
3 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
7 ms |
352 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
6 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
256 KB |
Output is correct |
24 |
Correct |
6 ms |
384 KB |
Output is correct |
25 |
Correct |
9 ms |
384 KB |
Output is correct |
26 |
Correct |
12 ms |
412 KB |
Output is correct |
27 |
Correct |
11 ms |
384 KB |
Output is correct |
28 |
Correct |
12 ms |
384 KB |
Output is correct |
29 |
Correct |
12 ms |
384 KB |
Output is correct |
30 |
Correct |
15 ms |
384 KB |
Output is correct |
31 |
Correct |
14 ms |
388 KB |
Output is correct |
32 |
Correct |
13 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
300 KB |
Output is correct |
7 |
Correct |
3 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
256 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
3 ms |
256 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
256 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
256 KB |
Output is correct |
26 |
Correct |
2 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
3 ms |
256 KB |
Output is correct |
31 |
Correct |
3 ms |
356 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
33 |
Correct |
3 ms |
256 KB |
Output is correct |
34 |
Correct |
2 ms |
256 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
2 ms |
384 KB |
Output is correct |
37 |
Correct |
3 ms |
256 KB |
Output is correct |
38 |
Correct |
2 ms |
256 KB |
Output is correct |
39 |
Correct |
4 ms |
256 KB |
Output is correct |
40 |
Correct |
4 ms |
256 KB |
Output is correct |
41 |
Correct |
5 ms |
256 KB |
Output is correct |
42 |
Correct |
6 ms |
384 KB |
Output is correct |
43 |
Correct |
5 ms |
384 KB |
Output is correct |
44 |
Correct |
7 ms |
384 KB |
Output is correct |
45 |
Correct |
6 ms |
384 KB |
Output is correct |
46 |
Correct |
7 ms |
384 KB |
Output is correct |
47 |
Correct |
5 ms |
384 KB |
Output is correct |
48 |
Correct |
7 ms |
384 KB |
Output is correct |
49 |
Correct |
8 ms |
384 KB |
Output is correct |
50 |
Correct |
11 ms |
384 KB |
Output is correct |
51 |
Correct |
21 ms |
384 KB |
Output is correct |
52 |
Correct |
12 ms |
384 KB |
Output is correct |
53 |
Correct |
12 ms |
384 KB |
Output is correct |
54 |
Correct |
12 ms |
384 KB |
Output is correct |
55 |
Correct |
20 ms |
384 KB |
Output is correct |
56 |
Correct |
3 ms |
256 KB |
Output is correct |
57 |
Correct |
4 ms |
384 KB |
Output is correct |
58 |
Correct |
4 ms |
384 KB |
Output is correct |
59 |
Correct |
4 ms |
384 KB |
Output is correct |
60 |
Correct |
4 ms |
384 KB |
Output is correct |
61 |
Correct |
4 ms |
384 KB |
Output is correct |
62 |
Correct |
6 ms |
384 KB |
Output is correct |
63 |
Correct |
5 ms |
384 KB |
Output is correct |
64 |
Correct |
13 ms |
388 KB |
Output is correct |
65 |
Correct |
3 ms |
256 KB |
Output is correct |
66 |
Correct |
3 ms |
428 KB |
Output is correct |
67 |
Correct |
4 ms |
384 KB |
Output is correct |
68 |
Correct |
5 ms |
384 KB |
Output is correct |
69 |
Correct |
5 ms |
384 KB |
Output is correct |
70 |
Correct |
4 ms |
384 KB |
Output is correct |
71 |
Correct |
4 ms |
384 KB |
Output is correct |
72 |
Correct |
6 ms |
384 KB |
Output is correct |
73 |
Correct |
6 ms |
384 KB |
Output is correct |
74 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 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 |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
404 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
256 KB |
Output is correct |
13 |
Correct |
3 ms |
384 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 |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
304 KB |
Output is correct |
18 |
Correct |
3 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
3 ms |
256 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
256 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
256 KB |
Output is correct |
25 |
Correct |
2 ms |
384 KB |
Output is correct |
26 |
Correct |
4 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
256 KB |
Output is correct |
28 |
Correct |
6 ms |
384 KB |
Output is correct |
29 |
Correct |
6 ms |
384 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
33 |
Correct |
5 ms |
384 KB |
Output is correct |
34 |
Correct |
5 ms |
384 KB |
Output is correct |
35 |
Correct |
6 ms |
256 KB |
Output is correct |
36 |
Correct |
8 ms |
384 KB |
Output is correct |
37 |
Correct |
12 ms |
428 KB |
Output is correct |
38 |
Correct |
17 ms |
384 KB |
Output is correct |
39 |
Correct |
12 ms |
384 KB |
Output is correct |
40 |
Correct |
15 ms |
384 KB |
Output is correct |
41 |
Correct |
12 ms |
384 KB |
Output is correct |
42 |
Correct |
16 ms |
384 KB |
Output is correct |
43 |
Correct |
4 ms |
384 KB |
Output is correct |
44 |
Correct |
6 ms |
384 KB |
Output is correct |
45 |
Correct |
5 ms |
384 KB |
Output is correct |
46 |
Correct |
5 ms |
384 KB |
Output is correct |
47 |
Correct |
5 ms |
384 KB |
Output is correct |
48 |
Correct |
8 ms |
384 KB |
Output is correct |
49 |
Correct |
8 ms |
384 KB |
Output is correct |
50 |
Correct |
7 ms |
384 KB |
Output is correct |
51 |
Correct |
7 ms |
412 KB |
Output is correct |
52 |
Correct |
92 ms |
544 KB |
Output is correct |
53 |
Correct |
117 ms |
588 KB |
Output is correct |
54 |
Correct |
179 ms |
624 KB |
Output is correct |
55 |
Correct |
154 ms |
752 KB |
Output is correct |
56 |
Correct |
434 ms |
952 KB |
Output is correct |
57 |
Correct |
456 ms |
896 KB |
Output is correct |
58 |
Correct |
287 ms |
896 KB |
Output is correct |
59 |
Correct |
299 ms |
980 KB |
Output is correct |
60 |
Correct |
498 ms |
948 KB |
Output is correct |
61 |
Correct |
9 ms |
384 KB |
Output is correct |
62 |
Correct |
78 ms |
580 KB |
Output is correct |
63 |
Correct |
149 ms |
748 KB |
Output is correct |
64 |
Correct |
139 ms |
752 KB |
Output is correct |
65 |
Correct |
257 ms |
768 KB |
Output is correct |
66 |
Correct |
310 ms |
880 KB |
Output is correct |
67 |
Correct |
442 ms |
952 KB |
Output is correct |
68 |
Correct |
417 ms |
1064 KB |
Output is correct |
69 |
Correct |
383 ms |
1012 KB |
Output is correct |