#include<iostream>
#define int long long
using namespace std;
const int N=2e3+4;
bool dp[N][N];
int sum[N][N],ar[N];
pair<int,int> range[N];
long long sum1[N];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,i,j,k,a,b;
long long temp=0,l;
cin>>n>>a>>b;
for(i=1;i<=n;i++){
cin>>ar[i];
sum1[i]=sum1[i-1]+ar[i];
}
dp[0][0]=true;
for(i=0;i<=n;i++){
sum[i][0]=1;
}
for(i=60;i>=0;i--){
l=(1ll<<i);
for(j=1;j<=n;j++){
range[j].first=n+1;
range[j].second=-1;
for(k=0;k<j;k++){
if(((sum1[j]-sum1[k])|temp)-temp<l){
range[j].first=min(range[j].first,k);
range[j].second=max(range[j].second,k);
}
}
}
for(j=1;j<=n;j++){
for(k=1;k<=min(j,b);k++){
if(range[j].second>=range[j].first){
l=sum[range[j].second][k-1];
if(range[j].first){
l-=sum[range[j].first-1][k-1];
}
if(l){
dp[j][k]=true;
}
else{
dp[j][k]=false;
}
}
else{
dp[j][k]=false;
}
sum[j][k]=sum[j-1][k]+dp[j][k];
if(j==n){
if(k>=a&&dp[j][k]){
break;
}
if(k==b){
temp|=(1ll<<i);
}
}
}
}
}
cout<<temp;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
476 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |