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;
#define int long long
const int inf=1e18;
signed main() {
cin.tie(0)->sync_with_stdio(false);
int n, a, b;
cin >> n >> a >> b;
vector<int> pre(n+1, 0);
for (int i = 1; i <= n; ++i) {
cin >> pre[i];
pre[i]+=pre[i-1];
}
vector<vector<int>> dp(n+1, vector<int>(b+1, inf));
for (int i = 0; i <= n; ++i) dp[i][0]=pre[i];
for (int k = 1; k <= b; ++k) {
for (int i = k; i <= n; ++i) {
for (int j = k-1; j < i; ++j) {
dp[i][k]=min(dp[i][k], dp[j][k-1]|(pre[i]-pre[j]));
} //cout << dp[i][k] << ' ';
} //cout << '\n';
} //cout << '\n';
int m=inf;
for (int i = a-1; i < b; ++i) {
m=min(m, dp[n][i]);
} cout << m << '\n';
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... |