# include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 2;
int n, a[N], dp[N][N], l, r;
long long pref[N], ans;
bool ok(long long x, int ind){
for(int i = ind; i <= 40; i ++){
if((x >> i) % 2 != (ans >> i) % 2)
return 0;
}
return 1;
}
bool check(int ind){
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for(int i = 1; i <= r; i ++){
for(int j = 1; j <= n; j ++){
for(int k = 0; k < j; k ++){
if(ok(pref[j] - pref[k], ind)){
dp[i][j] |= dp[i - 1][k];
}
}
}
}
int ret = 0;
for(int i = l; i <= r; i ++){
ret |= dp[i][n];
}
return ret;
}
int main(){
cin >> n >> l >> r;
for(int i = 1; i <= n; i ++){
cin >> a[i];
pref[i] = pref[i - 1] + a[i];
}
for(int i = 40; i >= 0; i --){
if(!check(i))
ans += (1LL << i);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
154 ms |
16084 KB |
Output is correct |
2 |
Incorrect |
138 ms |
16000 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
16088 KB |
Output is correct |
2 |
Incorrect |
60 ms |
16000 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
16000 KB |
Output is correct |
2 |
Incorrect |
60 ms |
16000 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
16088 KB |
Output is correct |
2 |
Incorrect |
147 ms |
16048 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
16088 KB |
Output is correct |
2 |
Incorrect |
58 ms |
15996 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |