#include<bits/stdc++.h>
using namespace std;
int Y[1010];
long long qs[1010];
long long dp[1010][1010];
long long sum (int i, int j) {
return qs[j]-qs[i-1];
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, A, B;
cin >> N >> A >> B;
for (int i = 1; i <= N; i++) {
cin >> Y[i];
qs[i] = qs[i-1] + Y[i];
}
for (int i = 1; i <= N; i++) {
dp[1][i] = sum(1, i);
// cerr << dp[1][i] << ' ';
}
for (int i = 2; i <= N; i++) {
for (int j = i; j <= N; j++) {
// split 1 - j into i partitions
dp[i][j] = 1e15;
for (int k = 1; k < j; k++) {
dp[i][j] = min(dp[i][j], dp[i-1][k] | sum(k+1, j));
}
// cerr << endl << i << ' ' << j << ' ' << dp[i][j];
}
}
long long ans = 1e15;
for (int i = A; i <= B; i++) {
ans = min(ans, dp[i][N]);
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
400 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |