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;
const ll INF = 1000000000LL * 2001LL;
int n, a, b;
ll arr[2001];
ll dp[2001][2001];
ll solve(int pos, int cnt) {
if (pos == n) {
if (a <= cnt && cnt <= b) return 0;
else return INF;
}
ll& ret = dp[pos][cnt];
if (ret != -1) return ret;
ret = INF;
ll sum = 0;
for (int i = pos; i < n; i++) {
sum += arr[i];
ret = min(ret, solve(i+1, cnt+1)|sum);
}
return ret;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> a >> b;
for (int i = 0; i < n; i++) cin >> arr[i];
memset(dp, -1, sizeof(dp));
cout << solve(0, 0);
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... |