# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
297489 | AaronNaidu | Bali Sculptures (APIO15_sculpture) | C++14 | 1083 ms | 504 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;
typedef long long ll;
ll n, a, b;
ll y[2001];
ll prefSums[2001];
ll minAns = 1000000000000;
void makeSubset(int x, vector<int> v) {
if (x == n-1)
{
v.push_back(n-1);
if (a <= v.size() and v.size() <= b)
{
ll thisAns = prefSums[v[0]];
ll thisSum = 0;
for (int i = 1; i < v.size(); i++)
{
thisSum = prefSums[v[i]] - prefSums[v[i-1]];
thisAns |= thisSum;
}
minAns = min(minAns, thisAns);
}
return;
}
v.push_back(x);
makeSubset(x+1, v);
v.pop_back();
makeSubset(x+1, v);
}
int main() {
cin >> n >> a >> b;
cin >> y[0];
prefSums[0] = y[0];
for (int i = 1; i < n; i++)
{
cin >> y[i];
prefSums[i] = prefSums[i-1] + y[i];
}
makeSubset(0, {});
cout << minAns << "\n";
}
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... |