This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define MAXN 101
int n,p,q;
ll a[MAXN];
ll pwr[42];
unordered_map<int,int> dp[MAXN];
bool check(ll x){
ll o;
for(int i=0;i<=n;i++)
dp[i].clear();
dp[0][0]=1;
for(int i=1;i<=n;i++){
o=0;
for(int j=i;j<=n;j++){
o+=a[j];
for(int k=0;k<42;k++){
if((x&pwr[k])==0
&& (o&pwr[k])!=0) break;
if(k>40)
for(auto& l:dp[i-1])
dp[j][l.ff+1]=1;
}
}
}
for(int i=p;i<=q;i++)
if(dp[n][i]==1)
return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin>>n>>p>>q;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=pwr[0]=1;i<42;i++)
pwr[i]=pwr[i-1]*2;
ll o=pwr[41]-1;
for(int i=40;i>=0;i--)
if(check(o-pwr[i]))
o-=pwr[i];
cout<<o;
}
# | 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... |