This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n, a, b;
cin >> n >> a >> b;
vector<ll> y(n);
for (int i = 0; i < n; ++i) {
cin >> y[i];
}
vector<ll> pref(n + 1, 0);
partial_sum(y.begin(), y.end(), pref.begin() + 1);
ll ans = 0;
for (int bit = 40; bit >= 0; --bit) {
bool dp[b + 1][n + 1];
memset(dp, 0, sizeof(dp));
dp[0][0] = true;
ll b1 = ans >> bit;
bool p = false;
for (int i = 0; i < b; ++i) {
for (int j = 0; j <= n; ++j) {
if (!dp[i][j]) continue;
for (int k = j + 1; k <= n; ++k) {
ll b2 = (pref[k] - pref[j]) >> bit;
dp[i + 1][k] |= (b1 | b2) == b1;
}
}
if (i + 1 >= a && dp[i + 1][n]) p = true;
}
if (!p) ans |= (1LL << bit);
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |