#include<iostream>
using namespace std;
typedef long long int lld;
#define INF 1000000000000000
lld DP[3000][3000];
lld Y[3000];
lld acc[3000];
lld solve(int pos, int groups){
if(DP[pos][groups]!=-1)return DP[pos][groups];
DP[pos][groups]=INF;
for(int j=0;j<pos;j++){
DP[pos][groups]=min(DP[pos][groups],(solve(j,groups-1)|(acc[pos]-acc[j])));
}
return DP[pos][groups];
}
int main(){
int n,a,b;
cin>>n>>a>>b;
for(int i=0;i<n;i++)cin>>Y[i];
acc[0]=0;
for(int i=0;i<n;i++)acc[i+1]=acc[i]+Y[i];
for(int i=0;i<=n;i++){
for(int j=0;j<=b;j++)DP[i][j]=-1;
}
for(int j=0;j<=b;j++)DP[0][j]=INF;
for(int i=0;i<=n;i++)DP[i][0]=INF;
DP[0][0]=0;
lld ans=INF;
/*for(int i=0;i<=n;i++){
for(int j=0;j<=b;j++)cout<<solve(i,j)<<" ";
cout<<endl;
}*/
for(int j=a;j<=b;j++){
ans=min(ans,solve(n,j));
//cout<<solve(n,j)<<endl;
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
492 KB |
Output is correct |
2 |
Incorrect |
3 ms |
636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
876 KB |
Output is correct |
2 |
Incorrect |
3 ms |
876 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
876 KB |
Output is correct |
2 |
Incorrect |
2 ms |
876 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
876 KB |
Output is correct |
2 |
Incorrect |
3 ms |
876 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |