#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int arr[101];
int dp[102][111];
int place;
long long res=0;
int get(int cur,int r){
if(cur==n+1){
if(a<=r && r<=b)return 1;
return 0;
}
if(dp[cur][r]!=-1)return dp[a][b];
long long sum=0;
int ok=0;
for(int i=cur;i<=n;i++){
sum+=arr[i];
if((res >> (place+1))==((res|sum) >> (place+1))){
if((sum & (1LL << place))==0)
ok=max(ok,get(i+1,r+1));
}
}
return dp[a][b]=ok;
}
int main(void){
cin >>n >> a >> b;
for(int i=1;i<=n;i++)
cin >> arr[i];
for(place=40;place>=0;place--){
memset(dp,-1,sizeof(dp));
if(!get(1,0)){
res+=(1LL << place);
}
}
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
10 ms |
336 KB |
Output is correct |
7 |
Correct |
39 ms |
296 KB |
Output is correct |
8 |
Correct |
306 ms |
312 KB |
Output is correct |
9 |
Correct |
318 ms |
332 KB |
Output is correct |
10 |
Correct |
301 ms |
332 KB |
Output is correct |
11 |
Correct |
330 ms |
332 KB |
Output is correct |
12 |
Correct |
327 ms |
332 KB |
Output is correct |
13 |
Correct |
311 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
10 ms |
336 KB |
Output is correct |
20 |
Correct |
39 ms |
204 KB |
Output is correct |
21 |
Correct |
298 ms |
312 KB |
Output is correct |
22 |
Correct |
301 ms |
332 KB |
Output is correct |
23 |
Correct |
299 ms |
204 KB |
Output is correct |
24 |
Correct |
309 ms |
312 KB |
Output is correct |
25 |
Correct |
356 ms |
332 KB |
Output is correct |
26 |
Correct |
303 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
292 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
39 ms |
332 KB |
Output is correct |
31 |
Correct |
73 ms |
332 KB |
Output is correct |
32 |
Correct |
76 ms |
312 KB |
Output is correct |
33 |
Correct |
119 ms |
204 KB |
Output is correct |
34 |
Correct |
115 ms |
312 KB |
Output is correct |
35 |
Correct |
222 ms |
312 KB |
Output is correct |
36 |
Correct |
195 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
10 ms |
332 KB |
Output is correct |
7 |
Correct |
38 ms |
204 KB |
Output is correct |
8 |
Correct |
305 ms |
312 KB |
Output is correct |
9 |
Correct |
338 ms |
312 KB |
Output is correct |
10 |
Correct |
303 ms |
316 KB |
Output is correct |
11 |
Correct |
325 ms |
204 KB |
Output is correct |
12 |
Correct |
314 ms |
332 KB |
Output is correct |
13 |
Correct |
327 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
10 ms |
332 KB |
Output is correct |
20 |
Correct |
38 ms |
204 KB |
Output is correct |
21 |
Correct |
313 ms |
312 KB |
Output is correct |
22 |
Correct |
313 ms |
332 KB |
Output is correct |
23 |
Correct |
301 ms |
332 KB |
Output is correct |
24 |
Correct |
302 ms |
372 KB |
Output is correct |
25 |
Correct |
309 ms |
312 KB |
Output is correct |
26 |
Correct |
310 ms |
332 KB |
Output is correct |
27 |
Correct |
623 ms |
324 KB |
Output is correct |
28 |
Execution timed out |
1090 ms |
332 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
13 ms |
336 KB |
Output is correct |
7 |
Correct |
39 ms |
204 KB |
Output is correct |
8 |
Correct |
307 ms |
332 KB |
Output is correct |
9 |
Correct |
366 ms |
332 KB |
Output is correct |
10 |
Correct |
304 ms |
312 KB |
Output is correct |
11 |
Correct |
331 ms |
324 KB |
Output is correct |
12 |
Correct |
304 ms |
312 KB |
Output is correct |
13 |
Correct |
320 ms |
332 KB |
Output is correct |
14 |
Correct |
610 ms |
332 KB |
Output is correct |
15 |
Execution timed out |
1084 ms |
332 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
10 ms |
332 KB |
Output is correct |
7 |
Correct |
39 ms |
332 KB |
Output is correct |
8 |
Correct |
305 ms |
332 KB |
Output is correct |
9 |
Correct |
333 ms |
312 KB |
Output is correct |
10 |
Correct |
321 ms |
324 KB |
Output is correct |
11 |
Correct |
329 ms |
312 KB |
Output is correct |
12 |
Correct |
308 ms |
332 KB |
Output is correct |
13 |
Correct |
304 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
10 ms |
332 KB |
Output is correct |
20 |
Correct |
48 ms |
316 KB |
Output is correct |
21 |
Correct |
306 ms |
332 KB |
Output is correct |
22 |
Correct |
303 ms |
312 KB |
Output is correct |
23 |
Correct |
310 ms |
312 KB |
Output is correct |
24 |
Correct |
304 ms |
316 KB |
Output is correct |
25 |
Correct |
315 ms |
332 KB |
Output is correct |
26 |
Correct |
314 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
39 ms |
204 KB |
Output is correct |
31 |
Correct |
73 ms |
204 KB |
Output is correct |
32 |
Correct |
73 ms |
332 KB |
Output is correct |
33 |
Correct |
128 ms |
332 KB |
Output is correct |
34 |
Correct |
113 ms |
332 KB |
Output is correct |
35 |
Correct |
200 ms |
332 KB |
Output is correct |
36 |
Correct |
197 ms |
332 KB |
Output is correct |
37 |
Correct |
647 ms |
324 KB |
Output is correct |
38 |
Execution timed out |
1089 ms |
204 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
10 ms |
296 KB |
Output is correct |
7 |
Correct |
40 ms |
204 KB |
Output is correct |
8 |
Correct |
308 ms |
332 KB |
Output is correct |
9 |
Correct |
307 ms |
332 KB |
Output is correct |
10 |
Correct |
305 ms |
324 KB |
Output is correct |
11 |
Correct |
298 ms |
312 KB |
Output is correct |
12 |
Correct |
309 ms |
332 KB |
Output is correct |
13 |
Correct |
307 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
40 ms |
204 KB |
Output is correct |
18 |
Correct |
74 ms |
332 KB |
Output is correct |
19 |
Correct |
72 ms |
312 KB |
Output is correct |
20 |
Correct |
117 ms |
332 KB |
Output is correct |
21 |
Correct |
112 ms |
332 KB |
Output is correct |
22 |
Correct |
198 ms |
204 KB |
Output is correct |
23 |
Correct |
193 ms |
332 KB |
Output is correct |
24 |
Correct |
606 ms |
332 KB |
Output is correct |
25 |
Execution timed out |
1099 ms |
204 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |