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>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
using namespace std;
typedef long long ll;
const int mxn = 2e3+5;
int N, A, B;
int a[mxn];
bitset<mxn> dp[mxn];
bool ok(ll mask){
fr(i, 0, N+1) dp[i] = 0;
dp[0][0] = 1;
fr(i, 1, N+1){
ll sum = 0;
for(int j = i; j >= 1; j --){
sum += a[j-1];
if((mask&sum) == sum){
dp[i] |= (dp[j-1]<<1);
}
}
}
bool r = false;
fr(i, A, B+1){
r |= dp[N][i];
}
return r;
}
void solve(){
cin >> N >> A >> B;
fr(i, 0, N){
cin >> a[i];
}
ll mask = (1LL<<41)-1;
for(int i = 40; i >= 0; i --){
mask ^= (1LL<<i);
if(!ok(mask)){
mask ^= (1LL<<i);
}
}
cout<<mask<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
# | 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... |