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;
#define all(v) (v).begin(), (v).end()
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n, A, B;
cin >> n >> A >> B;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(B));
for (int i = 0; i < n; i++) {
dp[i][0].push_back((i ? dp[i - 1][0][0] : 0) + a[i]);
for (int j = 1; j < B; j++) {
ll sm = 0;
for (int k = i; k > 0 && !dp[k - 1][j - 1].empty(); k--) {
sm += a[k];
for (auto l : dp[k - 1][j - 1]) dp[i][j].push_back(l | sm);
}
}
}
ll mn = LLONG_MAX;
for (int i = A - 1; i < B; i++) {
if (!dp[n - 1][i].empty()) mn = min(mn, *min_element(all(dp[n - 1][i])));
}
cout << mn << '\n';
}
# | 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... |