#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define fastInp ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
const int MAXN = 2005;
int y[MAXN];
int dp[MAXN][MAXN];
int pref[MAXN];
int get_sum(int l, int r) {
return pref[r] - pref[l - 1];
}
const int INF = INT_MAX;
signed main() {
fastInp;
int n, a, b;
cin >> n >> a >> b;
for (int i = 1; i <= n; i++) {
cin >> y[i];
pref[i] = pref[i - 1] + y[i];
}
for (int i = 0; i < MAXN; i++) {
for (int j = 0; j < MAXN; j++) {
dp[i][j] = INF;
}
}
dp[0][0] = 0;
for (int gr = 1; gr <= b; gr++) {
for (int i = gr; i <= n; i++) {
for (int last = 0; last < i; last++) {
if (dp[last][gr - 1] != INF) {
dp[i][gr] = min(dp[i][gr], dp[last][gr - 1] | get_sum(last + 1, i));
}
}
}
}
int ans = INT_MAX;
for (int gr = a; gr <= b; gr++) {
ans = min(ans, dp[n][gr]);
}
cout << ans << endl;
}
/*
6 1 3
8 1 2 1 5 4
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
15948 KB |
Output is correct |
2 |
Incorrect |
11 ms |
15948 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
15948 KB |
Output is correct |
2 |
Incorrect |
10 ms |
15948 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
15944 KB |
Output is correct |
2 |
Incorrect |
10 ms |
15948 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
15952 KB |
Output is correct |
2 |
Incorrect |
10 ms |
15948 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
16048 KB |
Output is correct |
2 |
Incorrect |
10 ms |
15948 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |