#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
const long long INF = 1e18;
int n, a, b, p[N];
long long ans = INF, sum[N], dp[N][N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> a >> b;
for(int i = 1; i <= n; i++) cin >> p[i], sum[i] = sum[i-1] + p[i];
for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) dp[i][j] = INF;
dp[0][0] = 0;
for(int i = 1; i <= n; i++) for(int j = 1; j <= i; j++) {
for(int k = 0; k < i; k++) dp[i][j] = min(dp[k][j-1] | (sum[i] - sum[k]), dp[i][j]);
}
for(int i = a; i <= b; i++) ans = min(dp[n][i], ans);
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
33484 KB |
Output is correct |
2 |
Incorrect |
0 ms |
33484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
33484 KB |
Output is correct |
2 |
Incorrect |
0 ms |
33484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
33484 KB |
Output is correct |
2 |
Incorrect |
0 ms |
33484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
33484 KB |
Output is correct |
2 |
Incorrect |
0 ms |
33484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
33484 KB |
Output is correct |
2 |
Incorrect |
0 ms |
33484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |