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;
int main() {
int n, a, b;
cin >> n >> a >> b;
vector<int> y(n);
for (int i = 0; i < n; ++i) {
cin >> y[i];
}
vector<int> pref(n + 1, 0);
partial_sum(y.begin(), y.end(), pref.begin() + 1);
bool dp[b + 1][n + 1][1 << 9];
memset(dp, 0, sizeof(dp));
dp[0][0][0] = true;
for (int i = 0; i < b; ++i) {
for (int j = 0; j <= n; ++j) {
for (int k = 0; k < 1 << 9; ++k) {
if (!dp[i][j][k]) continue;
for (int h = j + 1; h <= n; ++h) {
dp[i + 1][h][k | (pref[h] - pref[j])] = true;
}
}
}
}
int ans = INT_MAX;
for (int i = a; i <= b; ++i) {
for (int k = 0; k < 1 << 9; ++k) {
if (!dp[i][n][k]) continue;
ans = min(ans, k);
}
}
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... |