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;
typedef long long ll;
typedef pair<int, int> ii;
const int maxn = 2005;
ll dp[maxn][maxn], sum[maxn];
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
freopen("in", "r", stdin);
#endif
int n, a, b;
cin >> n >> a >> b;
for(int i = 1; i <= n; i++) {
cin >> sum[i]; sum[i] += sum[i-1];
}
for(int i = 0; i <= n; i++)
dp[0][i] = sum[i];
for(int k = 1; k < b; k++) {
for(int i = 1; i <= n; i++) {
dp[k][i] = 1e18;
for(int j = 0; j < i; j++) {
dp[k][i] = min(dp[k][i], dp[k - 1][j] | (sum[i] - sum[j]));
}
}
}
ll Min = 1e18;
for(int i = a-1; i < b; i++)
Min = min(Min, dp[i][n]);
cout << Min << endl;
}
# | 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... |