#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#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 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);
if(ret)
return dp[pos][num] = ret;
}
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 |
278 ms |
31864 KB |
Output is correct |
2 |
Correct |
332 ms |
31864 KB |
Output is correct |
3 |
Correct |
334 ms |
31736 KB |
Output is correct |
4 |
Correct |
305 ms |
31992 KB |
Output is correct |
5 |
Correct |
370 ms |
31864 KB |
Output is correct |
6 |
Correct |
293 ms |
31864 KB |
Output is correct |
7 |
Correct |
334 ms |
31864 KB |
Output is correct |
8 |
Correct |
332 ms |
31864 KB |
Output is correct |
9 |
Correct |
473 ms |
31864 KB |
Output is correct |
10 |
Correct |
356 ms |
31864 KB |
Output is correct |
11 |
Correct |
315 ms |
31980 KB |
Output is correct |
12 |
Correct |
381 ms |
31864 KB |
Output is correct |
13 |
Correct |
341 ms |
31964 KB |
Output is correct |
14 |
Correct |
264 ms |
31864 KB |
Output is correct |
15 |
Correct |
220 ms |
31736 KB |
Output is correct |
16 |
Correct |
270 ms |
31864 KB |
Output is correct |
17 |
Correct |
331 ms |
31864 KB |
Output is correct |
18 |
Correct |
269 ms |
31736 KB |
Output is correct |
19 |
Correct |
252 ms |
31952 KB |
Output is correct |
20 |
Correct |
272 ms |
31852 KB |
Output is correct |
21 |
Correct |
358 ms |
31992 KB |
Output is correct |
22 |
Correct |
413 ms |
31992 KB |
Output is correct |
23 |
Correct |
280 ms |
31736 KB |
Output is correct |
24 |
Correct |
316 ms |
31852 KB |
Output is correct |
25 |
Correct |
343 ms |
31852 KB |
Output is correct |
26 |
Correct |
306 ms |
31848 KB |
Output is correct |
27 |
Correct |
321 ms |
31852 KB |
Output is correct |
28 |
Correct |
255 ms |
31864 KB |
Output is correct |
29 |
Correct |
273 ms |
31884 KB |
Output is correct |
30 |
Correct |
293 ms |
31852 KB |
Output is correct |
31 |
Correct |
295 ms |
31864 KB |
Output is correct |
32 |
Correct |
306 ms |
31868 KB |
Output is correct |
33 |
Correct |
344 ms |
31888 KB |
Output is correct |
34 |
Correct |
346 ms |
31864 KB |
Output is correct |
35 |
Correct |
339 ms |
31992 KB |
Output is correct |
36 |
Correct |
318 ms |
31864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
306 ms |
31864 KB |
Output is correct |
2 |
Correct |
321 ms |
31856 KB |
Output is correct |
3 |
Correct |
310 ms |
31736 KB |
Output is correct |
4 |
Correct |
337 ms |
31864 KB |
Output is correct |
5 |
Correct |
343 ms |
31860 KB |
Output is correct |
6 |
Correct |
326 ms |
31864 KB |
Output is correct |
7 |
Correct |
338 ms |
31864 KB |
Output is correct |
8 |
Correct |
346 ms |
31848 KB |
Output is correct |
9 |
Correct |
345 ms |
31864 KB |
Output is correct |
10 |
Correct |
350 ms |
31856 KB |
Output is correct |
11 |
Correct |
340 ms |
31740 KB |
Output is correct |
12 |
Correct |
355 ms |
31848 KB |
Output is correct |
13 |
Correct |
345 ms |
31852 KB |
Output is correct |
14 |
Correct |
333 ms |
31852 KB |
Output is correct |
15 |
Correct |
337 ms |
31804 KB |
Output is correct |
16 |
Correct |
337 ms |
31780 KB |
Output is correct |
17 |
Correct |
345 ms |
31864 KB |
Output is correct |
18 |
Correct |
363 ms |
31852 KB |
Output is correct |
19 |
Correct |
356 ms |
31864 KB |
Output is correct |
20 |
Correct |
344 ms |
31736 KB |
Output is correct |
21 |
Correct |
335 ms |
31848 KB |
Output is correct |
22 |
Correct |
356 ms |
31852 KB |
Output is correct |
23 |
Correct |
344 ms |
31852 KB |
Output is correct |
24 |
Correct |
343 ms |
31860 KB |
Output is correct |
25 |
Correct |
348 ms |
31856 KB |
Output is correct |
26 |
Correct |
367 ms |
31856 KB |
Output is correct |
27 |
Correct |
353 ms |
31856 KB |
Output is correct |
28 |
Correct |
333 ms |
31864 KB |
Output is correct |
29 |
Correct |
331 ms |
31864 KB |
Output is correct |
30 |
Correct |
363 ms |
31864 KB |
Output is correct |
31 |
Correct |
344 ms |
31852 KB |
Output is correct |
32 |
Correct |
350 ms |
31848 KB |
Output is correct |
33 |
Correct |
354 ms |
31860 KB |
Output is correct |
34 |
Correct |
342 ms |
31732 KB |
Output is correct |
35 |
Correct |
359 ms |
31856 KB |
Output is correct |
36 |
Correct |
358 ms |
31852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
352 ms |
31856 KB |
Output is correct |
2 |
Correct |
350 ms |
31852 KB |
Output is correct |
3 |
Correct |
355 ms |
31848 KB |
Output is correct |
4 |
Correct |
371 ms |
31848 KB |
Output is correct |
5 |
Correct |
374 ms |
31848 KB |
Output is correct |
6 |
Correct |
359 ms |
31864 KB |
Output is correct |
7 |
Correct |
349 ms |
31844 KB |
Output is correct |
8 |
Correct |
356 ms |
31860 KB |
Output is correct |
9 |
Correct |
338 ms |
31868 KB |
Output is correct |
10 |
Correct |
363 ms |
31964 KB |
Output is correct |
11 |
Correct |
361 ms |
31736 KB |
Output is correct |
12 |
Correct |
374 ms |
31864 KB |
Output is correct |
13 |
Correct |
359 ms |
31864 KB |
Output is correct |
14 |
Correct |
348 ms |
31856 KB |
Output is correct |
15 |
Correct |
358 ms |
31864 KB |
Output is correct |
16 |
Correct |
357 ms |
31860 KB |
Output is correct |
17 |
Correct |
360 ms |
31860 KB |
Output is correct |
18 |
Correct |
340 ms |
31856 KB |
Output is correct |
19 |
Correct |
351 ms |
31848 KB |
Output is correct |
20 |
Correct |
358 ms |
31856 KB |
Output is correct |
21 |
Correct |
334 ms |
31876 KB |
Output is correct |
22 |
Correct |
359 ms |
31856 KB |
Output is correct |
23 |
Correct |
361 ms |
31736 KB |
Output is correct |
24 |
Correct |
357 ms |
31856 KB |
Output is correct |
25 |
Correct |
365 ms |
31864 KB |
Output is correct |
26 |
Correct |
368 ms |
31848 KB |
Output is correct |
27 |
Correct |
360 ms |
31856 KB |
Output is correct |
28 |
Correct |
354 ms |
31856 KB |
Output is correct |
29 |
Correct |
346 ms |
31852 KB |
Output is correct |
30 |
Correct |
394 ms |
31856 KB |
Output is correct |
31 |
Correct |
345 ms |
31856 KB |
Output is correct |
32 |
Correct |
361 ms |
31856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
358 ms |
31864 KB |
Output is correct |
2 |
Correct |
351 ms |
31860 KB |
Output is correct |
3 |
Correct |
357 ms |
31740 KB |
Output is correct |
4 |
Correct |
346 ms |
31848 KB |
Output is correct |
5 |
Correct |
351 ms |
31848 KB |
Output is correct |
6 |
Correct |
344 ms |
31740 KB |
Output is correct |
7 |
Correct |
342 ms |
31736 KB |
Output is correct |
8 |
Correct |
355 ms |
31852 KB |
Output is correct |
9 |
Correct |
322 ms |
31852 KB |
Output is correct |
10 |
Correct |
321 ms |
31864 KB |
Output is correct |
11 |
Correct |
333 ms |
31852 KB |
Output is correct |
12 |
Correct |
359 ms |
31848 KB |
Output is correct |
13 |
Correct |
360 ms |
31736 KB |
Output is correct |
14 |
Correct |
359 ms |
31848 KB |
Output is correct |
15 |
Correct |
364 ms |
31864 KB |
Output is correct |
16 |
Correct |
364 ms |
31852 KB |
Output is correct |
17 |
Correct |
419 ms |
31856 KB |
Output is correct |
18 |
Correct |
362 ms |
31852 KB |
Output is correct |
19 |
Correct |
358 ms |
31852 KB |
Output is correct |
20 |
Correct |
359 ms |
31736 KB |
Output is correct |
21 |
Correct |
411 ms |
31852 KB |
Output is correct |
22 |
Correct |
342 ms |
31868 KB |
Output is correct |
23 |
Correct |
358 ms |
31848 KB |
Output is correct |
24 |
Correct |
345 ms |
31852 KB |
Output is correct |
25 |
Correct |
350 ms |
31852 KB |
Output is correct |
26 |
Correct |
472 ms |
31852 KB |
Output is correct |
27 |
Correct |
359 ms |
31852 KB |
Output is correct |
28 |
Correct |
388 ms |
31856 KB |
Output is correct |
29 |
Correct |
355 ms |
31860 KB |
Output is correct |
30 |
Correct |
357 ms |
31856 KB |
Output is correct |
31 |
Correct |
353 ms |
31852 KB |
Output is correct |
32 |
Correct |
301 ms |
31852 KB |
Output is correct |
33 |
Correct |
355 ms |
31864 KB |
Output is correct |
34 |
Correct |
359 ms |
31848 KB |
Output is correct |
35 |
Correct |
360 ms |
31848 KB |
Output is correct |
36 |
Correct |
312 ms |
31740 KB |
Output is correct |
37 |
Correct |
333 ms |
31848 KB |
Output is correct |
38 |
Correct |
352 ms |
31864 KB |
Output is correct |
39 |
Correct |
348 ms |
31864 KB |
Output is correct |
40 |
Correct |
346 ms |
31856 KB |
Output is correct |
41 |
Correct |
337 ms |
31736 KB |
Output is correct |
42 |
Correct |
338 ms |
31860 KB |
Output is correct |
43 |
Correct |
354 ms |
31776 KB |
Output is correct |
44 |
Correct |
352 ms |
31852 KB |
Output is correct |
45 |
Correct |
301 ms |
31736 KB |
Output is correct |
46 |
Correct |
350 ms |
31852 KB |
Output is correct |
47 |
Correct |
352 ms |
31852 KB |
Output is correct |
48 |
Correct |
365 ms |
31852 KB |
Output is correct |
49 |
Correct |
371 ms |
31860 KB |
Output is correct |
50 |
Correct |
348 ms |
31852 KB |
Output is correct |
51 |
Correct |
338 ms |
31848 KB |
Output is correct |
52 |
Correct |
334 ms |
31736 KB |
Output is correct |
53 |
Correct |
389 ms |
31856 KB |
Output is correct |
54 |
Correct |
351 ms |
31856 KB |
Output is correct |
55 |
Correct |
349 ms |
31788 KB |
Output is correct |
56 |
Correct |
357 ms |
31856 KB |
Output is correct |
57 |
Correct |
365 ms |
31856 KB |
Output is correct |
58 |
Correct |
345 ms |
31868 KB |
Output is correct |
59 |
Correct |
342 ms |
31856 KB |
Output is correct |
60 |
Correct |
334 ms |
31864 KB |
Output is correct |
61 |
Correct |
357 ms |
31752 KB |
Output is correct |
62 |
Correct |
347 ms |
31864 KB |
Output is correct |
63 |
Correct |
428 ms |
31884 KB |
Output is correct |
64 |
Correct |
349 ms |
31860 KB |
Output is correct |
65 |
Correct |
340 ms |
31852 KB |
Output is correct |
66 |
Correct |
354 ms |
31852 KB |
Output is correct |
67 |
Correct |
344 ms |
31736 KB |
Output is correct |
68 |
Correct |
362 ms |
31856 KB |
Output is correct |
69 |
Correct |
350 ms |
31812 KB |
Output is correct |
70 |
Correct |
353 ms |
31864 KB |
Output is correct |
71 |
Correct |
379 ms |
31856 KB |
Output is correct |
72 |
Correct |
353 ms |
31856 KB |
Output is correct |
73 |
Correct |
361 ms |
31864 KB |
Output is correct |
74 |
Correct |
354 ms |
31852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
346 ms |
31848 KB |
Output is correct |
2 |
Correct |
512 ms |
31852 KB |
Output is correct |
3 |
Correct |
417 ms |
31964 KB |
Output is correct |
4 |
Correct |
348 ms |
31848 KB |
Output is correct |
5 |
Correct |
345 ms |
31852 KB |
Output is correct |
6 |
Correct |
365 ms |
31848 KB |
Output is correct |
7 |
Correct |
359 ms |
31848 KB |
Output is correct |
8 |
Correct |
357 ms |
31908 KB |
Output is correct |
9 |
Correct |
355 ms |
31844 KB |
Output is correct |
10 |
Correct |
361 ms |
31852 KB |
Output is correct |
11 |
Correct |
366 ms |
31864 KB |
Output is correct |
12 |
Correct |
361 ms |
31852 KB |
Output is correct |
13 |
Correct |
350 ms |
31848 KB |
Output is correct |
14 |
Correct |
352 ms |
31848 KB |
Output is correct |
15 |
Correct |
315 ms |
31736 KB |
Output is correct |
16 |
Correct |
356 ms |
31740 KB |
Output is correct |
17 |
Correct |
356 ms |
31848 KB |
Output is correct |
18 |
Correct |
341 ms |
31848 KB |
Output is correct |
19 |
Correct |
345 ms |
31848 KB |
Output is correct |
20 |
Correct |
335 ms |
31848 KB |
Output is correct |
21 |
Correct |
334 ms |
31864 KB |
Output is correct |
22 |
Correct |
340 ms |
31736 KB |
Output is correct |
23 |
Correct |
362 ms |
31864 KB |
Output is correct |
24 |
Correct |
361 ms |
31852 KB |
Output is correct |
25 |
Correct |
337 ms |
31848 KB |
Output is correct |
26 |
Correct |
359 ms |
31860 KB |
Output is correct |
27 |
Correct |
334 ms |
31856 KB |
Output is correct |
28 |
Correct |
347 ms |
31856 KB |
Output is correct |
29 |
Correct |
339 ms |
31852 KB |
Output is correct |
30 |
Correct |
360 ms |
31848 KB |
Output is correct |
31 |
Correct |
360 ms |
31860 KB |
Output is correct |
32 |
Correct |
354 ms |
31848 KB |
Output is correct |
33 |
Correct |
358 ms |
31852 KB |
Output is correct |
34 |
Correct |
356 ms |
31848 KB |
Output is correct |
35 |
Correct |
351 ms |
31864 KB |
Output is correct |
36 |
Correct |
289 ms |
31864 KB |
Output is correct |
37 |
Correct |
282 ms |
31736 KB |
Output is correct |
38 |
Correct |
351 ms |
31848 KB |
Output is correct |
39 |
Correct |
357 ms |
31788 KB |
Output is correct |
40 |
Correct |
328 ms |
31736 KB |
Output is correct |
41 |
Correct |
253 ms |
31864 KB |
Output is correct |
42 |
Correct |
257 ms |
31852 KB |
Output is correct |
43 |
Correct |
308 ms |
31868 KB |
Output is correct |
44 |
Correct |
316 ms |
31736 KB |
Output is correct |
45 |
Correct |
289 ms |
31852 KB |
Output is correct |
46 |
Correct |
295 ms |
31864 KB |
Output is correct |
47 |
Correct |
289 ms |
31856 KB |
Output is correct |
48 |
Correct |
293 ms |
31736 KB |
Output is correct |
49 |
Correct |
260 ms |
31736 KB |
Output is correct |
50 |
Correct |
239 ms |
31736 KB |
Output is correct |
51 |
Correct |
292 ms |
31984 KB |
Output is correct |
52 |
Execution timed out |
1077 ms |
31864 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |