#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=10;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 |
0 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 |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
9 ms |
332 KB |
Output is correct |
8 |
Correct |
56 ms |
312 KB |
Output is correct |
9 |
Correct |
51 ms |
204 KB |
Output is correct |
10 |
Correct |
48 ms |
204 KB |
Output is correct |
11 |
Correct |
45 ms |
204 KB |
Output is correct |
12 |
Correct |
54 ms |
332 KB |
Output is correct |
13 |
Correct |
54 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 |
0 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 |
3 ms |
332 KB |
Output is correct |
20 |
Correct |
7 ms |
336 KB |
Output is correct |
21 |
Correct |
53 ms |
312 KB |
Output is correct |
22 |
Correct |
44 ms |
332 KB |
Output is correct |
23 |
Correct |
46 ms |
204 KB |
Output is correct |
24 |
Correct |
47 ms |
332 KB |
Output is correct |
25 |
Correct |
58 ms |
204 KB |
Output is correct |
26 |
Correct |
51 ms |
324 KB |
Output is correct |
27 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 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 |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
9 ms |
332 KB |
Output is correct |
8 |
Correct |
52 ms |
204 KB |
Output is correct |
9 |
Correct |
54 ms |
332 KB |
Output is correct |
10 |
Correct |
57 ms |
332 KB |
Output is correct |
11 |
Correct |
44 ms |
204 KB |
Output is correct |
12 |
Correct |
67 ms |
204 KB |
Output is correct |
13 |
Correct |
55 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 |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
7 ms |
332 KB |
Output is correct |
21 |
Correct |
52 ms |
332 KB |
Output is correct |
22 |
Correct |
44 ms |
204 KB |
Output is correct |
23 |
Correct |
46 ms |
204 KB |
Output is correct |
24 |
Correct |
44 ms |
204 KB |
Output is correct |
25 |
Correct |
56 ms |
324 KB |
Output is correct |
26 |
Correct |
51 ms |
204 KB |
Output is correct |
27 |
Correct |
100 ms |
332 KB |
Output is correct |
28 |
Execution timed out |
1077 ms |
204 KB |
Time limit exceeded |
29 |
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 |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
7 ms |
332 KB |
Output is correct |
8 |
Correct |
67 ms |
204 KB |
Output is correct |
9 |
Correct |
51 ms |
204 KB |
Output is correct |
10 |
Correct |
48 ms |
324 KB |
Output is correct |
11 |
Correct |
45 ms |
312 KB |
Output is correct |
12 |
Correct |
56 ms |
204 KB |
Output is correct |
13 |
Correct |
56 ms |
324 KB |
Output is correct |
14 |
Correct |
101 ms |
332 KB |
Output is correct |
15 |
Execution timed out |
1079 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 |
0 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 |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
7 ms |
328 KB |
Output is correct |
8 |
Correct |
53 ms |
204 KB |
Output is correct |
9 |
Correct |
55 ms |
332 KB |
Output is correct |
10 |
Correct |
47 ms |
332 KB |
Output is correct |
11 |
Correct |
46 ms |
332 KB |
Output is correct |
12 |
Correct |
54 ms |
308 KB |
Output is correct |
13 |
Correct |
54 ms |
204 KB |
Output is correct |
14 |
Correct |
0 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 |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
6 ms |
332 KB |
Output is correct |
21 |
Correct |
51 ms |
204 KB |
Output is correct |
22 |
Correct |
44 ms |
312 KB |
Output is correct |
23 |
Correct |
55 ms |
332 KB |
Output is correct |
24 |
Correct |
73 ms |
312 KB |
Output is correct |
25 |
Correct |
57 ms |
308 KB |
Output is correct |
26 |
Correct |
53 ms |
312 KB |
Output is correct |
27 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
7 ms |
332 KB |
Output is correct |
8 |
Correct |
52 ms |
204 KB |
Output is correct |
9 |
Correct |
52 ms |
204 KB |
Output is correct |
10 |
Correct |
56 ms |
332 KB |
Output is correct |
11 |
Correct |
44 ms |
332 KB |
Output is correct |
12 |
Correct |
54 ms |
204 KB |
Output is correct |
13 |
Correct |
54 ms |
332 KB |
Output is correct |
14 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |