#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 2e3 + 2;
int64 dp[maxn][maxn];
int64 pref [maxn];
int64 arr[maxn];
int main() {
for (int i = 0; i < maxn; i++) for (int j = 0; j < maxn; j++) dp[i][j] = 1e15;
int n,a,b;
cin >> n >> a >> b;
for (int i = 1; i <= n; i++){
cin >> arr[i];
pref[i] = pref[i-1] + arr[i];
dp[i][1] = pref[i];
}
for (int k = 2; k <= b; k++){
for (int r = k; r <= n; r++){
for (int l = k; l <= r; l++){
dp[r][k] = min(dp[r][k], dp[l-1][k-1] | (pref[r] - pref[l - 1]));
}
}
}
int64 rs = 1e15;
for (int i = a; i <= b; i++){
rs = min(rs, dp[n][i]);
}
cout << rs << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
31572 KB |
Output is correct |
2 |
Incorrect |
13 ms |
31572 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
31684 KB |
Output is correct |
2 |
Incorrect |
13 ms |
31680 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
31592 KB |
Output is correct |
2 |
Incorrect |
13 ms |
31656 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
31572 KB |
Output is correct |
2 |
Incorrect |
13 ms |
31564 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
31600 KB |
Output is correct |
2 |
Incorrect |
15 ms |
31572 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |