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<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 104
#define INF 1e9+7
using namespace std;
ll n,a,b,ar[N];
ll dp[N][N][N];
ll psum[N];
ll get_sum(ll i,ll j)
{
if(i == 0)
return psum[j];
return psum[j]-psum[i-1];
}
ll solve(ll cur,ll start,ll g)
{
if(g > b)
return INF;
if(cur == n)
{
if(g < a)
return INF;
return get_sum(start,n-1);
}
if(dp[cur][start][g])
return dp[cur][start][g];
// cout << cur << " " << start << " " << g << endl;
return dp[cur][start][g] = min(solve(cur+1,start,g),get_sum(start,cur)|solve(cur+1,cur+1,g+1));
}
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> a >> b;
rep(i,0,n)
{
cin >> ar[i];
if(i == 0)
psum[i] = ar[i];
else
psum[i] = ar[i]+psum[i-1];
}
cout << solve(0,0,1);
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... |