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;
using ll = long long;
int main() {
int n, a, b;
cin >> n >> a >> b;
vector<ll> y(n);
for (int i = 0; i < n; ++i) {
cin >> y[i];
}
vector<ll> pref(n + 1, 0);
partial_sum(y.begin(), y.end(), pref.begin() + 1);
ll ans = LLONG_MAX;
for (ll i = 0; i < 1LL << (n - 1); ++i) {
int set_bits = __builtin_popcount(i) + 1;
if (set_bits < a || set_bits > b) continue;
int last = 0;
ll res = 0;
for (int j = i; j; j -= j & -j) {
int k = __builtin_ctz(j) + 1;
res |= pref[k] - pref[last];
last = k;
}
res |= pref[n] - pref[last];
ans = min(ans, res);
}
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... |