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;
const int mod=1e9+7;
long long n,y[2050],dp[2050][2050],a,b;
long long f(int x,int g)
{
if(x==n&&a<=g&&g<=b)return 0;
if(x==n)return 1e18;
//if(dp[x][g]!=-1)return dp[x][g];
long long ans=1e18,sum=0;
for(int i=x;i<n;i++)
{
sum+=y[i];
ans=min(ans,(f(i+1,g+1)|sum));
}
return dp[x][g]=ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("empty.in","r",stdin);
//freopen("empty.out","w",stdout);
memset(dp,-1,sizeof dp);
cin>>n>>a>>b;
for(int i=0;i<n;i++)cin>>y[i];
cout<<f(0,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... |