# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104640 | YottaByte | Bali Sculptures (APIO15_sculpture) | C++14 | 513 ms | 512 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 <bits/stdc++.h>
using namespace std;
const int N = 25;
long long n, a, b, ar[N];
long long ans = 1e18;
void calc(long long mask) {
int one = __builtin_popcount(mask) + 1;
if((mask >> (n - 1)) & 1) return;
if(a <= one && one <= b) {
long long sum = 0, temp = 0;
for(int i = 0; i < n; i++) {
sum = sum + ar[i];
if(mask & (1 << i)) {
temp = temp | sum;
sum = 0;
}
}
temp = temp | sum;
if(ans > temp) {
ans = temp;
}
}
}
main() {
cin >> n >> a >> b;
for(int i = 0; i < n; i++) {
cin >> ar[i];
}
for(long long i = 0; i < (1 << n); i++) {
calc(i);
}
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... |