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 mxn = 2002;
int dp[mxn][mxn], y[mxn], p[mxn];
signed main() {
std::ios::sync_with_stdio(0);
std::cout.tie(0);
std::cin.tie(0);
#ifdef saarang
freopen("/home/saarang/Documents/cp/input.txt", "r", stdin);
freopen("/home/saarang/Documents/cp/output.txt", "w", stdout);
#endif
int n, a, b;
cin >> n >> a >> b;
for(int i = 1; i <= n; i++)
cin >> y[i];
for(int i = 1; i <= n; i++)
p[i] = p[i - 1] + y[i];
memset(dp, 0x7f, sizeof dp);
dp[0][0] = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= i; j++) {
int sum = 0;
for(int k = i; k; k--) {
sum += y[k];
dp[i][j] = min(dp[i][j], dp[k - 1][j - 1] | sum);
}
}
}
int ans = 1e15;
for(int j = a; j <= b; j++)
ans = min(ans, dp[n][j]);
cout << ans << '\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... |