# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104563 | YottaByte | Bali Sculptures (APIO15_sculpture) | C++14 | 1061 ms | 384 KiB |
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 <iostream>
using namespace std;
#define int long long
#define pc __builtin_popcount
const int N = 21, inf = 1073741824;
int n, a, b, ans = inf, ar[N];
void calc(int mask) {
if(pc(mask) + 1 > b) {
return;
}
if(a <= pc(mask) + 1 && pc(mask) + 1 <= b) {
int sum = 0, temp = 0;
for(int i = 0; i < n; i++) {
sum += ar[i];
if(mask & (1 << i)) {
temp |= sum;
sum = 0;
}
}
temp |= sum;
ans = min(ans, temp);
}
if(pc(mask) + 1 == b) {
return;
}
for(int i = 0; i < n; i++) {
if(mask >> i & 1); else {
calc(1 << i | mask);
}
}
}
main() {
cin >> n >> a >> b;
for(int i = 0; i < n; i++) {
cin >> ar[i];
}
calc(0);
cout << ans << endl;
}
Compilation message (stderr)
# | 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... |