#include <bits/stdc++.h>
#define N 2005
using namespace std;
typedef long long ll;
int n, A, B, v[N];
ll dp[N][N], sum[N], ans = 200000000000000000LL;
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>A>>B;
for(int i = 1; i <= n; i++)
{
cin>>v[i], sum[i] = sum[i - 1] + (ll)v[i], dp[i][1] = sum[i];
if(A <= 1 && 1 <= B && i == n) ans = min(ans, dp[i][1]);
}
for(int k = 2; k <= B; k++)
{
for(int i = 1; i <= n; i++)
{
dp[i][k] = 200000000000000000LL;
if(i < k) continue;
for(int j = 1; j <= i; j++)
{
if(j < k - 1) continue;
dp[i][k] = min( (dp[j - 1][k - 1] | (sum[i] - sum[j - 1])), dp[i][k]);
//cout<<dp[j - 1][k - 1]<<" "<<(sum[i] - sum[j - 1])<<" "<<(dp[j - 1][k - 1] | (sum[i] - sum[j - 1]))<<"\n";
}
if(A <= k && k <= B && i == n) ans = min(ans, dp[i][k]);
//cout<<i<<" "<<k<<" "<<dp[i][k]<<"\n";
}
}
cout<<ans<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Incorrect |
1 ms |
484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
556 KB |
Output is correct |
2 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |