///~~~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=29;i>=0;i--)
if(check(o-pwr[i]))
o-=pwr[i];
cout<<o;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |