#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
const int N = 2e3 + 5;
const int M = 205;
const ll INF = 1e18;
ll a[N],ans,n,x,y,pre[N],dp[N][2];
ll get(int l,int r) {
return pre[r] - pre[l - 1];
}
void f(int l,int r,int optl,int optr) {
if (l > r || optl > optr)
return;
int mid = (l + r) / 2;
int new_opt = mid;
for (int i = max(mid,optl) ; i <= optr ; i++) {
if (dp[mid][0] > (dp[i + 1][1] | get(mid, i))) {
dp[mid][0] = (dp[i + 1][1] | get(mid,i));
new_opt = i;
}
}
f(l,mid - 1,new_opt,optr);
f(mid + 1,r,optl,new_opt);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n >> x >> y;
for (int i = 1 ; i <= n ; i++) {
cin >> a[i];
pre[i] = pre[i - 1] + a[i];
}
for (int i = 1 ; i <= y ; i++) {
for (int j = 1 ; j <= n ; j++) {
dp[j][1] = dp[j][0];
dp[j][0] = INF;
}
f(1,n,1,n);
if (i >= x)
ans = max(ans,dp[1][0]);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
448 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |