# include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 2;
int n, a[N], dp[N][N], l, r;
long long pref[N], ans;
bool ok(long long x, int ind){
for(int i = ind; i <= 40; i ++){
if((x >> i) % 2 && (ans >> i) % 2 == 0)
return 0;
}
return 1;
}
bool check(int ind){
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for(int i = 1; i <= r; i ++){
for(int j = 1; j <= n; j ++){
for(int k = 0; k < j; k ++){
if(ok(pref[j] - pref[k], ind)){
dp[i][j] |= dp[i - 1][k];
}
}
}
}
int ret = 0;
for(int i = l; i <= r; i ++){
ret |= dp[i][n];
}
return ret;
}
int main(){
cin >> n >> l >> r;
for(int i = 1; i <= n; i ++){
cin >> a[i];
pref[i] = pref[i - 1] + a[i];
}
for(int i = 40; i >= 0; i --){
if(!check(i))
ans += (1LL << i);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
16120 KB |
Output is correct |
2 |
Correct |
127 ms |
16000 KB |
Output is correct |
3 |
Correct |
143 ms |
16000 KB |
Output is correct |
4 |
Correct |
140 ms |
16056 KB |
Output is correct |
5 |
Correct |
142 ms |
15992 KB |
Output is correct |
6 |
Correct |
128 ms |
16060 KB |
Output is correct |
7 |
Correct |
167 ms |
16120 KB |
Output is correct |
8 |
Correct |
152 ms |
16040 KB |
Output is correct |
9 |
Correct |
149 ms |
16092 KB |
Output is correct |
10 |
Correct |
144 ms |
16084 KB |
Output is correct |
11 |
Correct |
147 ms |
16000 KB |
Output is correct |
12 |
Correct |
134 ms |
16092 KB |
Output is correct |
13 |
Correct |
139 ms |
16000 KB |
Output is correct |
14 |
Correct |
141 ms |
16048 KB |
Output is correct |
15 |
Correct |
133 ms |
16000 KB |
Output is correct |
16 |
Correct |
161 ms |
16140 KB |
Output is correct |
17 |
Correct |
135 ms |
16000 KB |
Output is correct |
18 |
Correct |
148 ms |
16124 KB |
Output is correct |
19 |
Correct |
126 ms |
16052 KB |
Output is correct |
20 |
Correct |
70 ms |
16128 KB |
Output is correct |
21 |
Correct |
73 ms |
16000 KB |
Output is correct |
22 |
Correct |
141 ms |
16000 KB |
Output is correct |
23 |
Correct |
144 ms |
16048 KB |
Output is correct |
24 |
Correct |
146 ms |
16120 KB |
Output is correct |
25 |
Correct |
136 ms |
16000 KB |
Output is correct |
26 |
Correct |
137 ms |
16000 KB |
Output is correct |
27 |
Correct |
92 ms |
16000 KB |
Output is correct |
28 |
Correct |
121 ms |
16052 KB |
Output is correct |
29 |
Correct |
135 ms |
16000 KB |
Output is correct |
30 |
Correct |
140 ms |
16056 KB |
Output is correct |
31 |
Correct |
136 ms |
16056 KB |
Output is correct |
32 |
Correct |
160 ms |
16064 KB |
Output is correct |
33 |
Correct |
118 ms |
16048 KB |
Output is correct |
34 |
Correct |
141 ms |
16000 KB |
Output is correct |
35 |
Correct |
149 ms |
16000 KB |
Output is correct |
36 |
Correct |
143 ms |
16000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
16056 KB |
Output is correct |
2 |
Correct |
109 ms |
16092 KB |
Output is correct |
3 |
Correct |
145 ms |
16088 KB |
Output is correct |
4 |
Correct |
140 ms |
16120 KB |
Output is correct |
5 |
Correct |
133 ms |
16000 KB |
Output is correct |
6 |
Correct |
143 ms |
16056 KB |
Output is correct |
7 |
Correct |
105 ms |
16088 KB |
Output is correct |
8 |
Correct |
57 ms |
16000 KB |
Output is correct |
9 |
Correct |
73 ms |
16000 KB |
Output is correct |
10 |
Correct |
118 ms |
16000 KB |
Output is correct |
11 |
Correct |
124 ms |
16120 KB |
Output is correct |
12 |
Correct |
155 ms |
16000 KB |
Output is correct |
13 |
Correct |
114 ms |
16052 KB |
Output is correct |
14 |
Correct |
111 ms |
16000 KB |
Output is correct |
15 |
Correct |
80 ms |
16060 KB |
Output is correct |
16 |
Correct |
136 ms |
16100 KB |
Output is correct |
17 |
Correct |
141 ms |
16248 KB |
Output is correct |
18 |
Correct |
151 ms |
16128 KB |
Output is correct |
19 |
Correct |
169 ms |
16128 KB |
Output is correct |
20 |
Correct |
148 ms |
16124 KB |
Output is correct |
21 |
Correct |
124 ms |
16048 KB |
Output is correct |
22 |
Correct |
107 ms |
16000 KB |
Output is correct |
23 |
Correct |
125 ms |
16120 KB |
Output is correct |
24 |
Correct |
137 ms |
16056 KB |
Output is correct |
25 |
Correct |
143 ms |
16088 KB |
Output is correct |
26 |
Correct |
138 ms |
16092 KB |
Output is correct |
27 |
Correct |
126 ms |
16000 KB |
Output is correct |
28 |
Correct |
137 ms |
16120 KB |
Output is correct |
29 |
Correct |
130 ms |
16000 KB |
Output is correct |
30 |
Correct |
151 ms |
16000 KB |
Output is correct |
31 |
Correct |
152 ms |
16120 KB |
Output is correct |
32 |
Correct |
162 ms |
16000 KB |
Output is correct |
33 |
Correct |
70 ms |
16000 KB |
Output is correct |
34 |
Correct |
126 ms |
16000 KB |
Output is correct |
35 |
Correct |
139 ms |
16000 KB |
Output is correct |
36 |
Correct |
111 ms |
16000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
16052 KB |
Output is correct |
2 |
Correct |
117 ms |
16000 KB |
Output is correct |
3 |
Correct |
103 ms |
16048 KB |
Output is correct |
4 |
Correct |
104 ms |
16120 KB |
Output is correct |
5 |
Correct |
112 ms |
16112 KB |
Output is correct |
6 |
Correct |
90 ms |
16048 KB |
Output is correct |
7 |
Correct |
129 ms |
16048 KB |
Output is correct |
8 |
Correct |
117 ms |
16120 KB |
Output is correct |
9 |
Correct |
89 ms |
16000 KB |
Output is correct |
10 |
Correct |
60 ms |
16000 KB |
Output is correct |
11 |
Correct |
53 ms |
16000 KB |
Output is correct |
12 |
Correct |
95 ms |
16092 KB |
Output is correct |
13 |
Correct |
93 ms |
16120 KB |
Output is correct |
14 |
Correct |
112 ms |
16000 KB |
Output is correct |
15 |
Correct |
122 ms |
16128 KB |
Output is correct |
16 |
Correct |
118 ms |
16000 KB |
Output is correct |
17 |
Correct |
163 ms |
16000 KB |
Output is correct |
18 |
Correct |
174 ms |
16048 KB |
Output is correct |
19 |
Correct |
94 ms |
16084 KB |
Output is correct |
20 |
Correct |
101 ms |
16000 KB |
Output is correct |
21 |
Correct |
124 ms |
16128 KB |
Output is correct |
22 |
Correct |
149 ms |
16060 KB |
Output is correct |
23 |
Correct |
113 ms |
16000 KB |
Output is correct |
24 |
Correct |
164 ms |
16092 KB |
Output is correct |
25 |
Correct |
137 ms |
15972 KB |
Output is correct |
26 |
Correct |
194 ms |
16092 KB |
Output is correct |
27 |
Correct |
298 ms |
16092 KB |
Output is correct |
28 |
Correct |
481 ms |
16220 KB |
Output is correct |
29 |
Correct |
465 ms |
16120 KB |
Output is correct |
30 |
Correct |
156 ms |
16000 KB |
Output is correct |
31 |
Correct |
298 ms |
16052 KB |
Output is correct |
32 |
Correct |
481 ms |
16092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
145 ms |
16048 KB |
Output is correct |
2 |
Correct |
110 ms |
16000 KB |
Output is correct |
3 |
Correct |
95 ms |
16000 KB |
Output is correct |
4 |
Correct |
132 ms |
16000 KB |
Output is correct |
5 |
Correct |
96 ms |
16048 KB |
Output is correct |
6 |
Correct |
91 ms |
16000 KB |
Output is correct |
7 |
Correct |
82 ms |
16000 KB |
Output is correct |
8 |
Correct |
152 ms |
16048 KB |
Output is correct |
9 |
Correct |
134 ms |
16000 KB |
Output is correct |
10 |
Correct |
88 ms |
16000 KB |
Output is correct |
11 |
Correct |
98 ms |
16000 KB |
Output is correct |
12 |
Correct |
114 ms |
16000 KB |
Output is correct |
13 |
Correct |
135 ms |
16000 KB |
Output is correct |
14 |
Correct |
124 ms |
16120 KB |
Output is correct |
15 |
Correct |
84 ms |
16000 KB |
Output is correct |
16 |
Correct |
103 ms |
16000 KB |
Output is correct |
17 |
Correct |
108 ms |
16088 KB |
Output is correct |
18 |
Correct |
131 ms |
16052 KB |
Output is correct |
19 |
Correct |
119 ms |
16112 KB |
Output is correct |
20 |
Correct |
103 ms |
16000 KB |
Output is correct |
21 |
Correct |
135 ms |
16052 KB |
Output is correct |
22 |
Correct |
142 ms |
16120 KB |
Output is correct |
23 |
Correct |
148 ms |
16128 KB |
Output is correct |
24 |
Correct |
144 ms |
16120 KB |
Output is correct |
25 |
Correct |
105 ms |
16120 KB |
Output is correct |
26 |
Correct |
65 ms |
16000 KB |
Output is correct |
27 |
Correct |
121 ms |
16000 KB |
Output is correct |
28 |
Correct |
95 ms |
16048 KB |
Output is correct |
29 |
Correct |
132 ms |
16172 KB |
Output is correct |
30 |
Correct |
128 ms |
16000 KB |
Output is correct |
31 |
Correct |
59 ms |
16000 KB |
Output is correct |
32 |
Correct |
53 ms |
16000 KB |
Output is correct |
33 |
Correct |
134 ms |
16000 KB |
Output is correct |
34 |
Correct |
88 ms |
16048 KB |
Output is correct |
35 |
Correct |
63 ms |
15992 KB |
Output is correct |
36 |
Correct |
116 ms |
16048 KB |
Output is correct |
37 |
Correct |
113 ms |
16048 KB |
Output is correct |
38 |
Correct |
126 ms |
16052 KB |
Output is correct |
39 |
Correct |
105 ms |
16084 KB |
Output is correct |
40 |
Correct |
149 ms |
16128 KB |
Output is correct |
41 |
Correct |
161 ms |
16000 KB |
Output is correct |
42 |
Correct |
172 ms |
16084 KB |
Output is correct |
43 |
Correct |
136 ms |
16000 KB |
Output is correct |
44 |
Correct |
142 ms |
16120 KB |
Output is correct |
45 |
Correct |
146 ms |
16056 KB |
Output is correct |
46 |
Correct |
130 ms |
16092 KB |
Output is correct |
47 |
Correct |
129 ms |
16120 KB |
Output is correct |
48 |
Correct |
144 ms |
16000 KB |
Output is correct |
49 |
Correct |
175 ms |
16084 KB |
Output is correct |
50 |
Correct |
302 ms |
16120 KB |
Output is correct |
51 |
Correct |
500 ms |
16216 KB |
Output is correct |
52 |
Correct |
449 ms |
16120 KB |
Output is correct |
53 |
Correct |
130 ms |
16000 KB |
Output is correct |
54 |
Correct |
337 ms |
16120 KB |
Output is correct |
55 |
Correct |
406 ms |
16128 KB |
Output is correct |
56 |
Correct |
149 ms |
16048 KB |
Output is correct |
57 |
Correct |
211 ms |
16124 KB |
Output is correct |
58 |
Correct |
470 ms |
16120 KB |
Output is correct |
59 |
Correct |
835 ms |
16000 KB |
Output is correct |
60 |
Correct |
268 ms |
16120 KB |
Output is correct |
61 |
Correct |
77 ms |
16000 KB |
Output is correct |
62 |
Correct |
610 ms |
16056 KB |
Output is correct |
63 |
Correct |
585 ms |
16120 KB |
Output is correct |
64 |
Correct |
435 ms |
16000 KB |
Output is correct |
65 |
Correct |
168 ms |
16000 KB |
Output is correct |
66 |
Correct |
180 ms |
16052 KB |
Output is correct |
67 |
Correct |
241 ms |
16196 KB |
Output is correct |
68 |
Correct |
428 ms |
16092 KB |
Output is correct |
69 |
Correct |
832 ms |
16092 KB |
Output is correct |
70 |
Correct |
276 ms |
16120 KB |
Output is correct |
71 |
Correct |
123 ms |
16092 KB |
Output is correct |
72 |
Correct |
634 ms |
16092 KB |
Output is correct |
73 |
Correct |
489 ms |
16000 KB |
Output is correct |
74 |
Correct |
405 ms |
16000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
153 ms |
16084 KB |
Output is correct |
2 |
Correct |
145 ms |
16000 KB |
Output is correct |
3 |
Correct |
128 ms |
15992 KB |
Output is correct |
4 |
Correct |
124 ms |
16120 KB |
Output is correct |
5 |
Correct |
112 ms |
16000 KB |
Output is correct |
6 |
Correct |
131 ms |
16000 KB |
Output is correct |
7 |
Correct |
96 ms |
16056 KB |
Output is correct |
8 |
Correct |
91 ms |
16088 KB |
Output is correct |
9 |
Correct |
125 ms |
16120 KB |
Output is correct |
10 |
Correct |
117 ms |
16000 KB |
Output is correct |
11 |
Correct |
92 ms |
16000 KB |
Output is correct |
12 |
Correct |
82 ms |
16000 KB |
Output is correct |
13 |
Correct |
100 ms |
16120 KB |
Output is correct |
14 |
Correct |
95 ms |
16000 KB |
Output is correct |
15 |
Correct |
109 ms |
16000 KB |
Output is correct |
16 |
Correct |
94 ms |
16120 KB |
Output is correct |
17 |
Correct |
107 ms |
16000 KB |
Output is correct |
18 |
Correct |
71 ms |
16000 KB |
Output is correct |
19 |
Correct |
86 ms |
16000 KB |
Output is correct |
20 |
Correct |
98 ms |
16000 KB |
Output is correct |
21 |
Correct |
105 ms |
16092 KB |
Output is correct |
22 |
Correct |
66 ms |
16088 KB |
Output is correct |
23 |
Correct |
100 ms |
16092 KB |
Output is correct |
24 |
Correct |
110 ms |
16000 KB |
Output is correct |
25 |
Correct |
104 ms |
16000 KB |
Output is correct |
26 |
Correct |
115 ms |
16056 KB |
Output is correct |
27 |
Correct |
138 ms |
16120 KB |
Output is correct |
28 |
Correct |
156 ms |
16052 KB |
Output is correct |
29 |
Correct |
129 ms |
16056 KB |
Output is correct |
30 |
Correct |
79 ms |
16156 KB |
Output is correct |
31 |
Correct |
139 ms |
16120 KB |
Output is correct |
32 |
Correct |
149 ms |
16000 KB |
Output is correct |
33 |
Correct |
142 ms |
16120 KB |
Output is correct |
34 |
Correct |
161 ms |
16096 KB |
Output is correct |
35 |
Correct |
146 ms |
16084 KB |
Output is correct |
36 |
Correct |
183 ms |
16000 KB |
Output is correct |
37 |
Correct |
310 ms |
16120 KB |
Output is correct |
38 |
Correct |
512 ms |
16120 KB |
Output is correct |
39 |
Correct |
443 ms |
16000 KB |
Output is correct |
40 |
Correct |
115 ms |
16000 KB |
Output is correct |
41 |
Correct |
304 ms |
16000 KB |
Output is correct |
42 |
Correct |
398 ms |
16120 KB |
Output is correct |
43 |
Correct |
146 ms |
16000 KB |
Output is correct |
44 |
Correct |
249 ms |
16052 KB |
Output is correct |
45 |
Correct |
465 ms |
16124 KB |
Output is correct |
46 |
Correct |
849 ms |
16120 KB |
Output is correct |
47 |
Correct |
254 ms |
16120 KB |
Output is correct |
48 |
Correct |
134 ms |
16120 KB |
Output is correct |
49 |
Correct |
669 ms |
16156 KB |
Output is correct |
50 |
Correct |
589 ms |
16120 KB |
Output is correct |
51 |
Correct |
275 ms |
16056 KB |
Output is correct |
52 |
Execution timed out |
1071 ms |
16000 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |