#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl
typedef long long ll;
typedef pair<int, int> point;
const int mod = 1e9 + 7;
int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}
const int MAXN = 2e3 + 5;
ll n, a, b, x[MAXN], prefix[MAXN], dp[MAXN][MAXN];
int get(int l, int r){
if(l > 0)
return prefix[r] - prefix[l - 1];
else
return prefix[r];
}
int rek(int pos, int num, ll forbidden){
if(pos < 0){
if(num >= a && num <= b)
return 1;
else
return 0;
}
if(dp[pos][num] != -1)
return dp[pos][num];
int ret = 0;
ll sum = 0;
for(int i = pos; i >= 0; --i){
sum += x[i];
if((sum & forbidden) == 0){
ret |= rek(i - 1, num + 1, forbidden);
}
}
return dp[pos][num] = ret;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> a >> b;
REP(i, n)
cin >> x[i];
ll forbidden = 0, sol = 0;
for(int i = 60; i >= 0; --i){
memset(dp, -1, sizeof(dp));
forbidden |= (1LL << i);
if(!rek(n - 1, 0, forbidden)){
forbidden ^= (1LL << i);
sol |= (1LL << i);
}
}
cout << sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
225 ms |
31864 KB |
Output is correct |
2 |
Correct |
311 ms |
31856 KB |
Output is correct |
3 |
Correct |
324 ms |
31864 KB |
Output is correct |
4 |
Correct |
317 ms |
31992 KB |
Output is correct |
5 |
Correct |
369 ms |
31868 KB |
Output is correct |
6 |
Correct |
360 ms |
31944 KB |
Output is correct |
7 |
Correct |
303 ms |
31864 KB |
Output is correct |
8 |
Correct |
329 ms |
31816 KB |
Output is correct |
9 |
Correct |
326 ms |
31736 KB |
Output is correct |
10 |
Correct |
349 ms |
31964 KB |
Output is correct |
11 |
Correct |
319 ms |
31864 KB |
Output is correct |
12 |
Correct |
293 ms |
31852 KB |
Output is correct |
13 |
Correct |
297 ms |
31864 KB |
Output is correct |
14 |
Correct |
308 ms |
31992 KB |
Output is correct |
15 |
Correct |
324 ms |
31864 KB |
Output is correct |
16 |
Correct |
284 ms |
31864 KB |
Output is correct |
17 |
Correct |
275 ms |
31864 KB |
Output is correct |
18 |
Correct |
346 ms |
31844 KB |
Output is correct |
19 |
Correct |
318 ms |
31860 KB |
Output is correct |
20 |
Correct |
314 ms |
31964 KB |
Output is correct |
21 |
Correct |
317 ms |
31892 KB |
Output is correct |
22 |
Correct |
292 ms |
31864 KB |
Output is correct |
23 |
Correct |
395 ms |
31864 KB |
Output is correct |
24 |
Correct |
278 ms |
31864 KB |
Output is correct |
25 |
Correct |
259 ms |
31736 KB |
Output is correct |
26 |
Correct |
372 ms |
31864 KB |
Output is correct |
27 |
Correct |
268 ms |
31868 KB |
Output is correct |
28 |
Correct |
325 ms |
31864 KB |
Output is correct |
29 |
Correct |
461 ms |
31992 KB |
Output is correct |
30 |
Correct |
332 ms |
31992 KB |
Output is correct |
31 |
Correct |
330 ms |
31864 KB |
Output is correct |
32 |
Correct |
347 ms |
31992 KB |
Output is correct |
33 |
Correct |
362 ms |
31864 KB |
Output is correct |
34 |
Correct |
356 ms |
31864 KB |
Output is correct |
35 |
Correct |
328 ms |
31964 KB |
Output is correct |
36 |
Correct |
337 ms |
31780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
321 ms |
31852 KB |
Output is correct |
2 |
Correct |
308 ms |
31848 KB |
Output is correct |
3 |
Correct |
308 ms |
31864 KB |
Output is correct |
4 |
Correct |
335 ms |
31864 KB |
Output is correct |
5 |
Correct |
334 ms |
31864 KB |
Output is correct |
6 |
Correct |
301 ms |
31864 KB |
Output is correct |
7 |
Correct |
339 ms |
31856 KB |
Output is correct |
8 |
Correct |
321 ms |
31864 KB |
Output is correct |
9 |
Correct |
301 ms |
31736 KB |
Output is correct |
10 |
Correct |
328 ms |
31864 KB |
Output is correct |
11 |
Correct |
312 ms |
31936 KB |
Output is correct |
12 |
Correct |
349 ms |
31864 KB |
Output is correct |
13 |
Correct |
336 ms |
31996 KB |
Output is correct |
14 |
Correct |
325 ms |
31992 KB |
Output is correct |
15 |
Correct |
329 ms |
31864 KB |
Output is correct |
16 |
Correct |
319 ms |
31964 KB |
Output is correct |
17 |
Correct |
367 ms |
31992 KB |
Output is correct |
18 |
Correct |
314 ms |
31864 KB |
Output is correct |
19 |
Correct |
370 ms |
31976 KB |
Output is correct |
20 |
Correct |
338 ms |
31864 KB |
Output is correct |
21 |
Correct |
329 ms |
31864 KB |
Output is correct |
22 |
Correct |
334 ms |
31864 KB |
Output is correct |
23 |
Correct |
338 ms |
31868 KB |
Output is correct |
24 |
Correct |
388 ms |
31964 KB |
Output is correct |
25 |
Correct |
332 ms |
31736 KB |
Output is correct |
26 |
Correct |
352 ms |
31864 KB |
Output is correct |
27 |
Correct |
352 ms |
31864 KB |
Output is correct |
28 |
Correct |
311 ms |
31900 KB |
Output is correct |
29 |
Correct |
382 ms |
31856 KB |
Output is correct |
30 |
Correct |
331 ms |
31736 KB |
Output is correct |
31 |
Correct |
316 ms |
31864 KB |
Output is correct |
32 |
Correct |
302 ms |
31736 KB |
Output is correct |
33 |
Correct |
322 ms |
31864 KB |
Output is correct |
34 |
Correct |
396 ms |
31864 KB |
Output is correct |
35 |
Correct |
344 ms |
31864 KB |
Output is correct |
36 |
Correct |
351 ms |
31864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
310 ms |
31868 KB |
Output is correct |
2 |
Correct |
425 ms |
31864 KB |
Output is correct |
3 |
Correct |
327 ms |
31864 KB |
Output is correct |
4 |
Correct |
317 ms |
31992 KB |
Output is correct |
5 |
Correct |
333 ms |
31992 KB |
Output is correct |
6 |
Correct |
293 ms |
31864 KB |
Output is correct |
7 |
Correct |
243 ms |
31864 KB |
Output is correct |
8 |
Correct |
300 ms |
31864 KB |
Output is correct |
9 |
Correct |
307 ms |
31884 KB |
Output is correct |
10 |
Correct |
262 ms |
31864 KB |
Output is correct |
11 |
Correct |
264 ms |
31736 KB |
Output is correct |
12 |
Correct |
301 ms |
31848 KB |
Output is correct |
13 |
Correct |
303 ms |
31736 KB |
Output is correct |
14 |
Correct |
325 ms |
31864 KB |
Output is correct |
15 |
Correct |
351 ms |
31864 KB |
Output is correct |
16 |
Correct |
279 ms |
31864 KB |
Output is correct |
17 |
Correct |
301 ms |
31736 KB |
Output is correct |
18 |
Correct |
245 ms |
31736 KB |
Output is correct |
19 |
Correct |
254 ms |
31856 KB |
Output is correct |
20 |
Correct |
332 ms |
31864 KB |
Output is correct |
21 |
Correct |
321 ms |
31848 KB |
Output is correct |
22 |
Correct |
341 ms |
31964 KB |
Output is correct |
23 |
Correct |
287 ms |
31864 KB |
Output is correct |
24 |
Correct |
304 ms |
31864 KB |
Output is correct |
25 |
Correct |
296 ms |
31864 KB |
Output is correct |
26 |
Correct |
356 ms |
31864 KB |
Output is correct |
27 |
Correct |
349 ms |
31996 KB |
Output is correct |
28 |
Correct |
347 ms |
31992 KB |
Output is correct |
29 |
Correct |
364 ms |
31964 KB |
Output is correct |
30 |
Correct |
399 ms |
31992 KB |
Output is correct |
31 |
Correct |
342 ms |
31868 KB |
Output is correct |
32 |
Correct |
313 ms |
31864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
256 ms |
31852 KB |
Output is correct |
2 |
Correct |
263 ms |
31864 KB |
Output is correct |
3 |
Correct |
283 ms |
31736 KB |
Output is correct |
4 |
Correct |
268 ms |
31864 KB |
Output is correct |
5 |
Correct |
281 ms |
31864 KB |
Output is correct |
6 |
Correct |
310 ms |
31864 KB |
Output is correct |
7 |
Correct |
340 ms |
31864 KB |
Output is correct |
8 |
Correct |
265 ms |
31736 KB |
Output is correct |
9 |
Correct |
271 ms |
31864 KB |
Output is correct |
10 |
Correct |
310 ms |
31968 KB |
Output is correct |
11 |
Correct |
310 ms |
31852 KB |
Output is correct |
12 |
Correct |
282 ms |
31736 KB |
Output is correct |
13 |
Correct |
340 ms |
31864 KB |
Output is correct |
14 |
Correct |
311 ms |
31864 KB |
Output is correct |
15 |
Correct |
250 ms |
31964 KB |
Output is correct |
16 |
Correct |
261 ms |
31736 KB |
Output is correct |
17 |
Correct |
478 ms |
31864 KB |
Output is correct |
18 |
Correct |
268 ms |
31848 KB |
Output is correct |
19 |
Correct |
247 ms |
31864 KB |
Output is correct |
20 |
Correct |
283 ms |
31736 KB |
Output is correct |
21 |
Correct |
304 ms |
31864 KB |
Output is correct |
22 |
Correct |
309 ms |
31864 KB |
Output is correct |
23 |
Correct |
267 ms |
31868 KB |
Output is correct |
24 |
Correct |
266 ms |
31736 KB |
Output is correct |
25 |
Correct |
273 ms |
31736 KB |
Output is correct |
26 |
Correct |
281 ms |
31992 KB |
Output is correct |
27 |
Correct |
263 ms |
31864 KB |
Output is correct |
28 |
Correct |
261 ms |
31736 KB |
Output is correct |
29 |
Correct |
299 ms |
31864 KB |
Output is correct |
30 |
Correct |
303 ms |
31736 KB |
Output is correct |
31 |
Correct |
308 ms |
31892 KB |
Output is correct |
32 |
Correct |
277 ms |
31964 KB |
Output is correct |
33 |
Correct |
343 ms |
31892 KB |
Output is correct |
34 |
Correct |
252 ms |
31864 KB |
Output is correct |
35 |
Correct |
310 ms |
31864 KB |
Output is correct |
36 |
Correct |
319 ms |
31896 KB |
Output is correct |
37 |
Correct |
316 ms |
31992 KB |
Output is correct |
38 |
Correct |
331 ms |
31864 KB |
Output is correct |
39 |
Correct |
275 ms |
31856 KB |
Output is correct |
40 |
Correct |
252 ms |
31864 KB |
Output is correct |
41 |
Correct |
281 ms |
31892 KB |
Output is correct |
42 |
Correct |
321 ms |
31864 KB |
Output is correct |
43 |
Correct |
260 ms |
31864 KB |
Output is correct |
44 |
Correct |
268 ms |
31864 KB |
Output is correct |
45 |
Correct |
339 ms |
31852 KB |
Output is correct |
46 |
Correct |
326 ms |
31992 KB |
Output is correct |
47 |
Correct |
316 ms |
31864 KB |
Output is correct |
48 |
Correct |
279 ms |
31864 KB |
Output is correct |
49 |
Correct |
336 ms |
31864 KB |
Output is correct |
50 |
Correct |
344 ms |
31864 KB |
Output is correct |
51 |
Correct |
378 ms |
31996 KB |
Output is correct |
52 |
Correct |
375 ms |
31864 KB |
Output is correct |
53 |
Correct |
384 ms |
31860 KB |
Output is correct |
54 |
Correct |
409 ms |
31868 KB |
Output is correct |
55 |
Correct |
369 ms |
31864 KB |
Output is correct |
56 |
Correct |
307 ms |
31864 KB |
Output is correct |
57 |
Correct |
339 ms |
31736 KB |
Output is correct |
58 |
Correct |
329 ms |
31960 KB |
Output is correct |
59 |
Correct |
310 ms |
31864 KB |
Output is correct |
60 |
Correct |
364 ms |
31992 KB |
Output is correct |
61 |
Correct |
364 ms |
31864 KB |
Output is correct |
62 |
Correct |
332 ms |
31736 KB |
Output is correct |
63 |
Correct |
350 ms |
31736 KB |
Output is correct |
64 |
Correct |
371 ms |
31852 KB |
Output is correct |
65 |
Correct |
266 ms |
31864 KB |
Output is correct |
66 |
Correct |
239 ms |
31860 KB |
Output is correct |
67 |
Correct |
346 ms |
31736 KB |
Output is correct |
68 |
Correct |
348 ms |
31864 KB |
Output is correct |
69 |
Correct |
333 ms |
31864 KB |
Output is correct |
70 |
Correct |
271 ms |
31780 KB |
Output is correct |
71 |
Correct |
323 ms |
31864 KB |
Output is correct |
72 |
Correct |
304 ms |
31736 KB |
Output is correct |
73 |
Correct |
327 ms |
31856 KB |
Output is correct |
74 |
Correct |
300 ms |
31736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
295 ms |
31860 KB |
Output is correct |
2 |
Correct |
276 ms |
31864 KB |
Output is correct |
3 |
Correct |
290 ms |
31892 KB |
Output is correct |
4 |
Correct |
270 ms |
31736 KB |
Output is correct |
5 |
Correct |
254 ms |
31864 KB |
Output is correct |
6 |
Correct |
333 ms |
31992 KB |
Output is correct |
7 |
Correct |
323 ms |
31996 KB |
Output is correct |
8 |
Correct |
341 ms |
31852 KB |
Output is correct |
9 |
Correct |
447 ms |
31864 KB |
Output is correct |
10 |
Correct |
328 ms |
31864 KB |
Output is correct |
11 |
Correct |
301 ms |
31992 KB |
Output is correct |
12 |
Correct |
309 ms |
31864 KB |
Output is correct |
13 |
Correct |
252 ms |
31864 KB |
Output is correct |
14 |
Correct |
244 ms |
31864 KB |
Output is correct |
15 |
Correct |
254 ms |
31864 KB |
Output is correct |
16 |
Correct |
325 ms |
31992 KB |
Output is correct |
17 |
Correct |
317 ms |
31864 KB |
Output is correct |
18 |
Correct |
328 ms |
31864 KB |
Output is correct |
19 |
Correct |
338 ms |
31864 KB |
Output is correct |
20 |
Correct |
349 ms |
31992 KB |
Output is correct |
21 |
Correct |
289 ms |
31864 KB |
Output is correct |
22 |
Correct |
256 ms |
31864 KB |
Output is correct |
23 |
Correct |
326 ms |
31888 KB |
Output is correct |
24 |
Correct |
242 ms |
31888 KB |
Output is correct |
25 |
Correct |
276 ms |
31908 KB |
Output is correct |
26 |
Correct |
263 ms |
31868 KB |
Output is correct |
27 |
Correct |
320 ms |
31864 KB |
Output is correct |
28 |
Correct |
279 ms |
31780 KB |
Output is correct |
29 |
Correct |
229 ms |
31736 KB |
Output is correct |
30 |
Correct |
231 ms |
31736 KB |
Output is correct |
31 |
Correct |
341 ms |
31852 KB |
Output is correct |
32 |
Correct |
284 ms |
31864 KB |
Output is correct |
33 |
Correct |
323 ms |
31864 KB |
Output is correct |
34 |
Correct |
260 ms |
31864 KB |
Output is correct |
35 |
Correct |
326 ms |
31964 KB |
Output is correct |
36 |
Correct |
359 ms |
31872 KB |
Output is correct |
37 |
Correct |
338 ms |
31992 KB |
Output is correct |
38 |
Correct |
394 ms |
31864 KB |
Output is correct |
39 |
Correct |
324 ms |
31864 KB |
Output is correct |
40 |
Correct |
350 ms |
31864 KB |
Output is correct |
41 |
Correct |
336 ms |
31864 KB |
Output is correct |
42 |
Correct |
377 ms |
31868 KB |
Output is correct |
43 |
Correct |
376 ms |
31888 KB |
Output is correct |
44 |
Correct |
332 ms |
31888 KB |
Output is correct |
45 |
Correct |
320 ms |
31964 KB |
Output is correct |
46 |
Correct |
319 ms |
31776 KB |
Output is correct |
47 |
Correct |
322 ms |
31736 KB |
Output is correct |
48 |
Correct |
320 ms |
31864 KB |
Output is correct |
49 |
Correct |
328 ms |
31864 KB |
Output is correct |
50 |
Correct |
308 ms |
31896 KB |
Output is correct |
51 |
Correct |
379 ms |
31864 KB |
Output is correct |
52 |
Execution timed out |
1087 ms |
31864 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |