This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
vector<ll> v;
int n;
const int N=107;
ll pre[N];
ll dp[N][N];
ll query(int l,int r){
return pre[r]-pre[l-1];
}
ll solve(int idx,int k){
if(idx==n+1) {
if(k==0) {
return 0;
}
return 1e9;
}
if(dp[idx][k]!=-1) return dp[idx][k];
ll ans=1e9;
for(int j=idx; j<=n; j++) {
ans=min(ans,query(idx,j) | solve(j+1,k-1));
}
return dp[idx][k]=ans;
}
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
cin>>n;
int a,b;
cin>>a>>b;
v.resize(n+1);
for(int i=1; i<=n; i++) {
cin>>v[i];
pre[i]=pre[i-1]+v[i];
}
memset(dp,-1,sizeof dp);
ll ans=1e10;
for(int i=a; i<=b; i++) {
ans=min(ans,solve(1,i));
}
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... |