#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];
long long ans=f(0,1);
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
33272 KB |
Output is correct |
2 |
Correct |
23 ms |
33272 KB |
Output is correct |
3 |
Incorrect |
24 ms |
33272 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
33272 KB |
Output is correct |
2 |
Correct |
23 ms |
33272 KB |
Output is correct |
3 |
Incorrect |
23 ms |
33272 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
33272 KB |
Output is correct |
2 |
Correct |
23 ms |
33272 KB |
Output is correct |
3 |
Incorrect |
23 ms |
33272 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
33272 KB |
Output is correct |
2 |
Correct |
23 ms |
33272 KB |
Output is correct |
3 |
Incorrect |
23 ms |
33272 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
33272 KB |
Output is correct |
2 |
Correct |
23 ms |
33272 KB |
Output is correct |
3 |
Incorrect |
24 ms |
33272 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |