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> y_pref(n + 1, 0);
partial_sum(y.begin(), y.end(), y_pref.begin() + 1);
vector<vector<ll>> dp(b + 1, vector<ll>(n + 1, LLONG_MAX));
dp[0][0] = 0;
for (int i = 1; i <= b; ++i) {
for (int j = 1; j <= n; ++j) {
for (int k = 0; k < j; ++k) {
if (dp[i - 1][k] == INT_MAX) continue;
dp[i][j] =
min(dp[i][j], dp[i - 1][k] | (y_pref[j] - y_pref[k]));
}
}
}
ll ans = LLONG_MAX;
for (int i = a; i <= b; ++i) {
ans = min(ans, dp[i][n]);
}
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... |