#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
typedef long double ld;
using namespace std;
int n, a, b;
ll num[2005], pre[2050];
ll dp[2005][2005];
ll c(int i, int j) {
return pre[j] - pre[i-1];
}
int main()
{
cin >> n >> a >> b;
ll mn = 1e18+7;
for(int i = 1; i <= n; i++) cin >> num[i];
for(int i = 1; i <= n; i++) pre[i] = pre[i-1] + num[i];
for(int p = a; p <= b; p++) {
for(int i = 1; i <= n; i++) dp[1][i] = pre[i];
for(int k = 2; k <= p; k++) {
for(int i = 1; i <= n; i++) {
dp[k][i] = 1e18+7;
for(int j = 1; j < i; j++) {
dp[k][i] = min(dp[k][i], dp[k-1][j] | c(j+1, i));
}
}
}
mn = min(mn, dp[p][n]);
}
cout << mn << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |