#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e18;
signed main() {
cin.tie(0)->sync_with_stdio(false);
int n, a, b;
cin >> n >> a >> b;
vector<int> pre(n+1, 0);
for (int i = 1; i <= n; ++i) {
cin >> pre[i];
pre[i]+=pre[i-1];
}
vector<vector<int>> dp(n+1, vector<int>(b+1, inf));
for (int i = 0; i <= n; ++i) dp[i][0]=pre[i];
for (int k = 1; k <= b; ++k) {
for (int i = k; i <= n; ++i) {
for (int j = k-1; j < i; ++j) {
dp[i][k]=min(dp[i][k], dp[j][k-1]|(pre[i]-pre[j]));
} //cout << dp[i][k] << ' ';
} //cout << '\n';
} //cout << '\n';
int m=inf;
for (int i = a; i <= b; ++i) {
m=min(m, dp[n][i]);
} cout << m << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
456 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |