#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx = 2005;
int n, A, B;
ll S[mx], ans;
bool dp1[105][105];
void solve1(){
ans = 0;
ll cur = 0;
for(int b = 41; b >= 0; b--){
ll t = cur | (1LL << b);
dp1[0][0] = true;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= i; j++){
dp1[i][j] = false;
for(int k = 0; k < i; k++){
ll ps = S[i] - S[k];
if(!(ps & t)){
dp1[i][j] |= dp1[k][j-1];
}
}
}
}
bool able = false;
for(int i = A; i <= B; i++){
able |= dp1[n][i];
}
if(able){
cur = t;
}else{
ans |= (1LL << b);
}
}
}
int dp2[mx];
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++){
dp2[i] = INT_MAX;
for(int j = 0; j < i; j++){
ll ps = S[i] - S[j];
if(!(ps & t)){
dp2[i] = min(dp2[i], dp2[j] + 1);
}
}
}
if(dp2[n] <= B){
cur = t;
}else{
ans |= (1LL << b);
}
}
}
void input(){
cin >> n >> A >> B;
for(int i = 1; i <= n; i++){
cin >> S[i];
S[i] += S[i-1];
}
}
int main(){
input();
n <= 100 ? solve1() : solve2();
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
1 ms |
352 KB |
Output is correct |
3 |
Correct |
1 ms |
404 KB |
Output is correct |
4 |
Correct |
2 ms |
404 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
604 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
2 ms |
608 KB |
Output is correct |
18 |
Correct |
1 ms |
732 KB |
Output is correct |
19 |
Correct |
2 ms |
732 KB |
Output is correct |
20 |
Correct |
2 ms |
732 KB |
Output is correct |
21 |
Correct |
2 ms |
732 KB |
Output is correct |
22 |
Correct |
2 ms |
744 KB |
Output is correct |
23 |
Correct |
2 ms |
744 KB |
Output is correct |
24 |
Correct |
2 ms |
744 KB |
Output is correct |
25 |
Correct |
2 ms |
744 KB |
Output is correct |
26 |
Correct |
2 ms |
744 KB |
Output is correct |
27 |
Correct |
2 ms |
744 KB |
Output is correct |
28 |
Correct |
1 ms |
744 KB |
Output is correct |
29 |
Correct |
1 ms |
744 KB |
Output is correct |
30 |
Correct |
2 ms |
744 KB |
Output is correct |
31 |
Correct |
2 ms |
744 KB |
Output is correct |
32 |
Correct |
2 ms |
744 KB |
Output is correct |
33 |
Correct |
2 ms |
744 KB |
Output is correct |
34 |
Correct |
2 ms |
744 KB |
Output is correct |
35 |
Correct |
2 ms |
744 KB |
Output is correct |
36 |
Correct |
2 ms |
744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
744 KB |
Output is correct |
2 |
Correct |
1 ms |
744 KB |
Output is correct |
3 |
Correct |
1 ms |
744 KB |
Output is correct |
4 |
Correct |
1 ms |
744 KB |
Output is correct |
5 |
Correct |
1 ms |
744 KB |
Output is correct |
6 |
Correct |
1 ms |
744 KB |
Output is correct |
7 |
Correct |
2 ms |
744 KB |
Output is correct |
8 |
Correct |
2 ms |
744 KB |
Output is correct |
9 |
Correct |
2 ms |
744 KB |
Output is correct |
10 |
Correct |
2 ms |
744 KB |
Output is correct |
11 |
Correct |
2 ms |
744 KB |
Output is correct |
12 |
Correct |
2 ms |
744 KB |
Output is correct |
13 |
Correct |
2 ms |
744 KB |
Output is correct |
14 |
Correct |
1 ms |
744 KB |
Output is correct |
15 |
Correct |
2 ms |
744 KB |
Output is correct |
16 |
Correct |
1 ms |
744 KB |
Output is correct |
17 |
Correct |
2 ms |
744 KB |
Output is correct |
18 |
Correct |
2 ms |
744 KB |
Output is correct |
19 |
Correct |
2 ms |
744 KB |
Output is correct |
20 |
Correct |
2 ms |
744 KB |
Output is correct |
21 |
Correct |
2 ms |
744 KB |
Output is correct |
22 |
Correct |
2 ms |
860 KB |
Output is correct |
23 |
Correct |
2 ms |
864 KB |
Output is correct |
24 |
Correct |
2 ms |
868 KB |
Output is correct |
25 |
Correct |
2 ms |
872 KB |
Output is correct |
26 |
Correct |
2 ms |
872 KB |
Output is correct |
27 |
Correct |
2 ms |
872 KB |
Output is correct |
28 |
Correct |
2 ms |
872 KB |
Output is correct |
29 |
Correct |
3 ms |
872 KB |
Output is correct |
30 |
Correct |
4 ms |
872 KB |
Output is correct |
31 |
Correct |
6 ms |
892 KB |
Output is correct |
32 |
Correct |
7 ms |
892 KB |
Output is correct |
33 |
Correct |
5 ms |
892 KB |
Output is correct |
34 |
Correct |
5 ms |
892 KB |
Output is correct |
35 |
Correct |
5 ms |
892 KB |
Output is correct |
36 |
Correct |
5 ms |
892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
892 KB |
Output is correct |
2 |
Correct |
2 ms |
892 KB |
Output is correct |
3 |
Correct |
2 ms |
892 KB |
Output is correct |
4 |
Correct |
1 ms |
892 KB |
Output is correct |
5 |
Correct |
1 ms |
892 KB |
Output is correct |
6 |
Correct |
2 ms |
892 KB |
Output is correct |
7 |
Correct |
2 ms |
892 KB |
Output is correct |
8 |
Correct |
2 ms |
892 KB |
Output is correct |
9 |
Correct |
2 ms |
892 KB |
Output is correct |
10 |
Correct |
2 ms |
892 KB |
Output is correct |
11 |
Correct |
2 ms |
892 KB |
Output is correct |
12 |
Correct |
2 ms |
892 KB |
Output is correct |
13 |
Correct |
2 ms |
892 KB |
Output is correct |
14 |
Correct |
2 ms |
892 KB |
Output is correct |
15 |
Correct |
2 ms |
892 KB |
Output is correct |
16 |
Correct |
3 ms |
892 KB |
Output is correct |
17 |
Correct |
3 ms |
892 KB |
Output is correct |
18 |
Correct |
5 ms |
892 KB |
Output is correct |
19 |
Correct |
5 ms |
892 KB |
Output is correct |
20 |
Correct |
5 ms |
920 KB |
Output is correct |
21 |
Correct |
6 ms |
920 KB |
Output is correct |
22 |
Correct |
5 ms |
920 KB |
Output is correct |
23 |
Correct |
5 ms |
920 KB |
Output is correct |
24 |
Correct |
5 ms |
920 KB |
Output is correct |
25 |
Correct |
11 ms |
920 KB |
Output is correct |
26 |
Correct |
18 ms |
920 KB |
Output is correct |
27 |
Correct |
26 ms |
920 KB |
Output is correct |
28 |
Correct |
33 ms |
920 KB |
Output is correct |
29 |
Correct |
32 ms |
920 KB |
Output is correct |
30 |
Correct |
39 ms |
920 KB |
Output is correct |
31 |
Correct |
33 ms |
920 KB |
Output is correct |
32 |
Correct |
33 ms |
920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
920 KB |
Output is correct |
2 |
Correct |
2 ms |
920 KB |
Output is correct |
3 |
Correct |
2 ms |
920 KB |
Output is correct |
4 |
Correct |
2 ms |
920 KB |
Output is correct |
5 |
Correct |
2 ms |
920 KB |
Output is correct |
6 |
Correct |
2 ms |
920 KB |
Output is correct |
7 |
Correct |
1 ms |
920 KB |
Output is correct |
8 |
Correct |
2 ms |
920 KB |
Output is correct |
9 |
Correct |
2 ms |
920 KB |
Output is correct |
10 |
Correct |
2 ms |
920 KB |
Output is correct |
11 |
Correct |
2 ms |
920 KB |
Output is correct |
12 |
Correct |
2 ms |
920 KB |
Output is correct |
13 |
Correct |
2 ms |
920 KB |
Output is correct |
14 |
Correct |
1 ms |
920 KB |
Output is correct |
15 |
Correct |
2 ms |
920 KB |
Output is correct |
16 |
Correct |
2 ms |
920 KB |
Output is correct |
17 |
Correct |
1 ms |
920 KB |
Output is correct |
18 |
Correct |
2 ms |
920 KB |
Output is correct |
19 |
Correct |
1 ms |
920 KB |
Output is correct |
20 |
Correct |
2 ms |
920 KB |
Output is correct |
21 |
Correct |
2 ms |
920 KB |
Output is correct |
22 |
Correct |
2 ms |
920 KB |
Output is correct |
23 |
Correct |
2 ms |
920 KB |
Output is correct |
24 |
Correct |
2 ms |
920 KB |
Output is correct |
25 |
Correct |
2 ms |
920 KB |
Output is correct |
26 |
Correct |
2 ms |
920 KB |
Output is correct |
27 |
Correct |
1 ms |
920 KB |
Output is correct |
28 |
Correct |
2 ms |
920 KB |
Output is correct |
29 |
Correct |
2 ms |
920 KB |
Output is correct |
30 |
Correct |
2 ms |
920 KB |
Output is correct |
31 |
Correct |
2 ms |
920 KB |
Output is correct |
32 |
Correct |
2 ms |
920 KB |
Output is correct |
33 |
Correct |
2 ms |
920 KB |
Output is correct |
34 |
Correct |
2 ms |
920 KB |
Output is correct |
35 |
Correct |
2 ms |
920 KB |
Output is correct |
36 |
Correct |
2 ms |
920 KB |
Output is correct |
37 |
Correct |
2 ms |
920 KB |
Output is correct |
38 |
Correct |
2 ms |
920 KB |
Output is correct |
39 |
Correct |
3 ms |
920 KB |
Output is correct |
40 |
Correct |
4 ms |
920 KB |
Output is correct |
41 |
Correct |
5 ms |
920 KB |
Output is correct |
42 |
Correct |
5 ms |
920 KB |
Output is correct |
43 |
Correct |
6 ms |
1032 KB |
Output is correct |
44 |
Correct |
6 ms |
1032 KB |
Output is correct |
45 |
Correct |
5 ms |
1032 KB |
Output is correct |
46 |
Correct |
5 ms |
1032 KB |
Output is correct |
47 |
Correct |
6 ms |
1032 KB |
Output is correct |
48 |
Correct |
10 ms |
1032 KB |
Output is correct |
49 |
Correct |
17 ms |
1032 KB |
Output is correct |
50 |
Correct |
24 ms |
1032 KB |
Output is correct |
51 |
Correct |
32 ms |
1032 KB |
Output is correct |
52 |
Correct |
33 ms |
1032 KB |
Output is correct |
53 |
Correct |
33 ms |
1032 KB |
Output is correct |
54 |
Correct |
33 ms |
1032 KB |
Output is correct |
55 |
Correct |
34 ms |
1032 KB |
Output is correct |
56 |
Correct |
4 ms |
1032 KB |
Output is correct |
57 |
Correct |
13 ms |
1092 KB |
Output is correct |
58 |
Correct |
21 ms |
1096 KB |
Output is correct |
59 |
Correct |
20 ms |
1096 KB |
Output is correct |
60 |
Correct |
19 ms |
1096 KB |
Output is correct |
61 |
Correct |
22 ms |
1096 KB |
Output is correct |
62 |
Correct |
25 ms |
1096 KB |
Output is correct |
63 |
Correct |
21 ms |
1116 KB |
Output is correct |
64 |
Correct |
26 ms |
1116 KB |
Output is correct |
65 |
Correct |
4 ms |
1116 KB |
Output is correct |
66 |
Correct |
7 ms |
1116 KB |
Output is correct |
67 |
Correct |
10 ms |
1116 KB |
Output is correct |
68 |
Correct |
18 ms |
1116 KB |
Output is correct |
69 |
Correct |
22 ms |
1148 KB |
Output is correct |
70 |
Correct |
20 ms |
1148 KB |
Output is correct |
71 |
Correct |
20 ms |
1148 KB |
Output is correct |
72 |
Correct |
24 ms |
1148 KB |
Output is correct |
73 |
Correct |
23 ms |
1148 KB |
Output is correct |
74 |
Correct |
23 ms |
1148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1148 KB |
Output is correct |
2 |
Correct |
1 ms |
1148 KB |
Output is correct |
3 |
Correct |
1 ms |
1148 KB |
Output is correct |
4 |
Correct |
2 ms |
1148 KB |
Output is correct |
5 |
Correct |
1 ms |
1148 KB |
Output is correct |
6 |
Correct |
2 ms |
1148 KB |
Output is correct |
7 |
Correct |
2 ms |
1148 KB |
Output is correct |
8 |
Correct |
2 ms |
1148 KB |
Output is correct |
9 |
Correct |
2 ms |
1148 KB |
Output is correct |
10 |
Correct |
2 ms |
1148 KB |
Output is correct |
11 |
Correct |
2 ms |
1148 KB |
Output is correct |
12 |
Correct |
2 ms |
1148 KB |
Output is correct |
13 |
Correct |
2 ms |
1148 KB |
Output is correct |
14 |
Correct |
1 ms |
1148 KB |
Output is correct |
15 |
Correct |
1 ms |
1148 KB |
Output is correct |
16 |
Correct |
1 ms |
1148 KB |
Output is correct |
17 |
Correct |
2 ms |
1148 KB |
Output is correct |
18 |
Correct |
2 ms |
1148 KB |
Output is correct |
19 |
Correct |
2 ms |
1148 KB |
Output is correct |
20 |
Correct |
2 ms |
1148 KB |
Output is correct |
21 |
Correct |
2 ms |
1148 KB |
Output is correct |
22 |
Correct |
2 ms |
1148 KB |
Output is correct |
23 |
Correct |
2 ms |
1148 KB |
Output is correct |
24 |
Correct |
2 ms |
1148 KB |
Output is correct |
25 |
Correct |
2 ms |
1148 KB |
Output is correct |
26 |
Correct |
3 ms |
1148 KB |
Output is correct |
27 |
Correct |
3 ms |
1148 KB |
Output is correct |
28 |
Correct |
5 ms |
1168 KB |
Output is correct |
29 |
Correct |
5 ms |
1168 KB |
Output is correct |
30 |
Correct |
5 ms |
1168 KB |
Output is correct |
31 |
Correct |
5 ms |
1168 KB |
Output is correct |
32 |
Correct |
5 ms |
1168 KB |
Output is correct |
33 |
Correct |
5 ms |
1168 KB |
Output is correct |
34 |
Correct |
6 ms |
1168 KB |
Output is correct |
35 |
Correct |
10 ms |
1168 KB |
Output is correct |
36 |
Correct |
16 ms |
1168 KB |
Output is correct |
37 |
Correct |
25 ms |
1168 KB |
Output is correct |
38 |
Correct |
32 ms |
1168 KB |
Output is correct |
39 |
Correct |
32 ms |
1168 KB |
Output is correct |
40 |
Correct |
33 ms |
1168 KB |
Output is correct |
41 |
Correct |
32 ms |
1168 KB |
Output is correct |
42 |
Correct |
32 ms |
1168 KB |
Output is correct |
43 |
Correct |
4 ms |
1168 KB |
Output is correct |
44 |
Correct |
11 ms |
1168 KB |
Output is correct |
45 |
Correct |
19 ms |
1168 KB |
Output is correct |
46 |
Correct |
20 ms |
1168 KB |
Output is correct |
47 |
Correct |
19 ms |
1168 KB |
Output is correct |
48 |
Correct |
20 ms |
1168 KB |
Output is correct |
49 |
Correct |
22 ms |
1168 KB |
Output is correct |
50 |
Correct |
21 ms |
1168 KB |
Output is correct |
51 |
Incorrect |
2 ms |
1168 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |