#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=35;place>=0;place--){
memset(dp,-1,sizeof(dp));
if(!get(1,0)){
res+=(1LL << place);
}
}
cout << res;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
9 ms |
332 KB |
Output is correct |
7 |
Correct |
34 ms |
312 KB |
Output is correct |
8 |
Correct |
263 ms |
324 KB |
Output is correct |
9 |
Correct |
260 ms |
332 KB |
Output is correct |
10 |
Correct |
257 ms |
332 KB |
Output is correct |
11 |
Correct |
253 ms |
332 KB |
Output is correct |
12 |
Correct |
271 ms |
204 KB |
Output is correct |
13 |
Correct |
266 ms |
204 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 |
9 ms |
332 KB |
Output is correct |
20 |
Correct |
35 ms |
204 KB |
Output is correct |
21 |
Correct |
264 ms |
332 KB |
Output is correct |
22 |
Correct |
276 ms |
324 KB |
Output is correct |
23 |
Correct |
262 ms |
332 KB |
Output is correct |
24 |
Correct |
258 ms |
308 KB |
Output is correct |
25 |
Correct |
268 ms |
312 KB |
Output is correct |
26 |
Correct |
263 ms |
204 KB |
Output is correct |
27 |
Correct |
0 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 |
18 ms |
332 KB |
Output is correct |
31 |
Correct |
30 ms |
204 KB |
Output is correct |
32 |
Correct |
31 ms |
204 KB |
Output is correct |
33 |
Correct |
88 ms |
324 KB |
Output is correct |
34 |
Correct |
75 ms |
204 KB |
Output is correct |
35 |
Correct |
151 ms |
312 KB |
Output is correct |
36 |
Correct |
164 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
9 ms |
328 KB |
Output is correct |
7 |
Correct |
33 ms |
204 KB |
Output is correct |
8 |
Correct |
266 ms |
312 KB |
Output is correct |
9 |
Correct |
271 ms |
332 KB |
Output is correct |
10 |
Correct |
272 ms |
312 KB |
Output is correct |
11 |
Correct |
255 ms |
332 KB |
Output is correct |
12 |
Correct |
272 ms |
332 KB |
Output is correct |
13 |
Correct |
270 ms |
204 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 |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
8 ms |
328 KB |
Output is correct |
20 |
Correct |
33 ms |
320 KB |
Output is correct |
21 |
Correct |
261 ms |
312 KB |
Output is correct |
22 |
Correct |
253 ms |
308 KB |
Output is correct |
23 |
Correct |
280 ms |
324 KB |
Output is correct |
24 |
Correct |
256 ms |
332 KB |
Output is correct |
25 |
Correct |
296 ms |
308 KB |
Output is correct |
26 |
Correct |
260 ms |
312 KB |
Output is correct |
27 |
Correct |
565 ms |
324 KB |
Output is correct |
28 |
Execution timed out |
1092 ms |
204 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 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 |
9 ms |
332 KB |
Output is correct |
7 |
Correct |
33 ms |
204 KB |
Output is correct |
8 |
Correct |
271 ms |
204 KB |
Output is correct |
9 |
Correct |
268 ms |
312 KB |
Output is correct |
10 |
Correct |
259 ms |
312 KB |
Output is correct |
11 |
Correct |
252 ms |
204 KB |
Output is correct |
12 |
Correct |
270 ms |
308 KB |
Output is correct |
13 |
Correct |
268 ms |
320 KB |
Output is correct |
14 |
Correct |
557 ms |
308 KB |
Output is correct |
15 |
Execution timed out |
1093 ms |
332 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
9 ms |
336 KB |
Output is correct |
7 |
Correct |
34 ms |
332 KB |
Output is correct |
8 |
Correct |
281 ms |
312 KB |
Output is correct |
9 |
Correct |
268 ms |
312 KB |
Output is correct |
10 |
Correct |
260 ms |
204 KB |
Output is correct |
11 |
Correct |
288 ms |
308 KB |
Output is correct |
12 |
Correct |
267 ms |
204 KB |
Output is correct |
13 |
Correct |
265 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 |
0 ms |
332 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
8 ms |
332 KB |
Output is correct |
20 |
Correct |
33 ms |
204 KB |
Output is correct |
21 |
Correct |
264 ms |
332 KB |
Output is correct |
22 |
Correct |
256 ms |
204 KB |
Output is correct |
23 |
Correct |
255 ms |
308 KB |
Output is correct |
24 |
Correct |
261 ms |
324 KB |
Output is correct |
25 |
Correct |
266 ms |
312 KB |
Output is correct |
26 |
Correct |
290 ms |
204 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 |
18 ms |
332 KB |
Output is correct |
31 |
Correct |
30 ms |
328 KB |
Output is correct |
32 |
Correct |
31 ms |
204 KB |
Output is correct |
33 |
Correct |
76 ms |
312 KB |
Output is correct |
34 |
Correct |
66 ms |
332 KB |
Output is correct |
35 |
Correct |
161 ms |
308 KB |
Output is correct |
36 |
Correct |
160 ms |
204 KB |
Output is correct |
37 |
Correct |
556 ms |
332 KB |
Output is correct |
38 |
Execution timed out |
1091 ms |
204 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
9 ms |
332 KB |
Output is correct |
7 |
Correct |
33 ms |
204 KB |
Output is correct |
8 |
Correct |
270 ms |
312 KB |
Output is correct |
9 |
Correct |
260 ms |
308 KB |
Output is correct |
10 |
Correct |
273 ms |
312 KB |
Output is correct |
11 |
Correct |
261 ms |
312 KB |
Output is correct |
12 |
Correct |
269 ms |
332 KB |
Output is correct |
13 |
Correct |
266 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 |
18 ms |
432 KB |
Output is correct |
18 |
Correct |
32 ms |
204 KB |
Output is correct |
19 |
Correct |
31 ms |
332 KB |
Output is correct |
20 |
Correct |
75 ms |
312 KB |
Output is correct |
21 |
Correct |
67 ms |
204 KB |
Output is correct |
22 |
Correct |
163 ms |
312 KB |
Output is correct |
23 |
Correct |
157 ms |
324 KB |
Output is correct |
24 |
Correct |
534 ms |
308 KB |
Output is correct |
25 |
Execution timed out |
1081 ms |
204 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |