이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
| # | 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... |