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;
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = 2005;
bitset<N>dp[N];
ll A[N];
int main(){
fastIO;
int n, a, b;
cin >> n >> a >> b;
for(int i = 1; i <= n; i ++ ){
cin >> A[i];
}
ll xf = 0;
ll nw;
ll sigma;
ll answ = 0;
bool res;
for(int lg = 40; lg >= 0; lg -- ){
nw = xf;
nw |= (1ll << lg);
for(int i = 0; i <= n; i ++ ){
for(int j = 0 ; j <= n; j ++ ){
dp[i][j]=0;
}
}
dp[0][0]=1;
for(int i = 1; i <= n; i ++ ){
sigma = 0;
for(int j = i; j > 0 ; j -- ){
sigma += A[j];
if((sigma & nw) > 0) continue;
dp[i] |= (dp[j-1] << 1);
}
}
res=false;
for(int k = a; k <= b; k ++ ){
if(dp[n][k]) res=true;
}
if(res){
xf = nw;
}
else{
answ |= (1ll << lg);
}
}
cout << answ << "\n";
return 0;
}
# | 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... |