#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxn = 2002;
int dp[mxn][mxn], y[mxn], p[mxn];
signed main() {
std::ios::sync_with_stdio(0);
std::cout.tie(0);
std::cin.tie(0);
#ifdef saarang
freopen("/home/saarang/Documents/cp/input.txt", "r", stdin);
freopen("/home/saarang/Documents/cp/output.txt", "w", stdout);
#endif
int n, a, b;
cin >> n >> a >> b;
for(int i = 1; i <= n; i++)
cin >> y[i];
for(int i = 1; i <= n; i++)
p[i] = p[i - 1] + y[i];
memset(dp, 0x7f, sizeof dp);
dp[0][0] = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= i; j++) {
int sum = 0;
for(int k = i; k; k--) {
sum += y[k];
dp[i][j] = min(dp[i][j], dp[k - 1][j - 1] | sum);
}
}
}
int ans = 1e18;
for(int j = a; j <= b; j++)
ans = min(ans, dp[n][j]);
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
31724 KB |
Output is correct |
2 |
Incorrect |
17 ms |
31724 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
31724 KB |
Output is correct |
2 |
Incorrect |
16 ms |
31724 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
31724 KB |
Output is correct |
2 |
Incorrect |
16 ms |
31724 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
31724 KB |
Output is correct |
2 |
Incorrect |
17 ms |
31724 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
31724 KB |
Output is correct |
2 |
Incorrect |
17 ms |
31872 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |