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;
#define int long long
signed main(){
int n, a, b;
cin >> n >> a >> b;
vector<int> v(n);
for (int i=0; i<n; i++) cin >> v[i];
int bsf = pow(10, 11);
for (int i=0; i<(1<<(n-1)); i++){
//cout << i << "\n";
int pc = 0;
for (int j=0; j<n-2; j++){
if (i & (1<<j)) pc++;
}
if (pc < a-1 || pc > b-1) continue;
//cout << pc << "\n";
vector<int> w;
int cur = 0;
for (int j=0; j<n; j++){
cur += v[j];
if (i & (1<<j) || j == n-1){
w.push_back(cur);
cur = 0;
}
}
int res = 0;
for (int x : w) res |= x;
//cout << i << " " << res << "\n";
bsf = min(bsf, res);
}
cout << bsf << "\n";
}
# | 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... |