#include <bits/stdc++.h>
using namespace std;
const int N=2005;
int arr[N];
long long mem1[N][N],sum[N];
long long mem2[N];
int n,a,b;
long long go(int ind,int gr)
{
if(ind>=n&&a<=gr&&gr<=b)
return 0;
if(ind>=n)
return (1LL<<50);
if(mem1[ind][gr]!=-1)
return mem1[ind][gr];
mem1[ind][gr]=(1LL<<50);
for(int i=ind;i<n;i++)
{
mem1[ind][gr]=min(mem1[ind][gr],(sum[i]-(ind?sum[ind-1]:0))|go(i+1,gr+1));
}
return mem1[ind][gr];
}
int main()
{
cin >> n >> a >> b;
for(int i=0;i<n;i++)
cin >> arr[i];
/*if(n>100)
{
cout << "m3lsh" << endl;
}
else
{*/
memset(mem1,-1,sizeof mem1);
for(int i=0;i<n;i++)
sum[i]=arr[i]+(i?sum[i-1]:0);
cout << go(0,1) << endl;
//}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
31736 KB |
Output is correct |
2 |
Correct |
28 ms |
31864 KB |
Output is correct |
3 |
Incorrect |
28 ms |
31736 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
31736 KB |
Output is correct |
2 |
Correct |
28 ms |
31864 KB |
Output is correct |
3 |
Incorrect |
28 ms |
31864 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
31836 KB |
Output is correct |
2 |
Correct |
28 ms |
31736 KB |
Output is correct |
3 |
Incorrect |
28 ms |
31744 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
31736 KB |
Output is correct |
2 |
Correct |
28 ms |
31832 KB |
Output is correct |
3 |
Incorrect |
29 ms |
31852 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
31736 KB |
Output is correct |
2 |
Correct |
29 ms |
31736 KB |
Output is correct |
3 |
Incorrect |
28 ms |
31824 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |