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>
#define int long long
#define see(x) cout<<#x<<"="<<x<<endl;
#define endl "\n"
using namespace std;
const int INF = 1e18;
int n, a, b, y[105];
int dp[105][105], pref[105];
int ans = INF;
void brute(int i, int res, int rem) {
if (rem < 0) return;
if (i == n) {
if (!rem) ans = min(ans, res);
return;
}
int sum = 0;
for (int j = i + 1; j <= n; j ++) {
sum += y[j];
brute(j, (res | sum), rem - 1);
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
*/
cin >> n >> a >> b;
for (int i = 1; i <= n; i ++) {
cin >> y[i];
pref[i] = pref[i-1] + y[i];
}
for (int i = a; i <= b; i ++) {
brute(0, 0, i);
}
cout << ans << endl;
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... |