This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# 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 == 0)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |