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;
const ll inf=(1e18)+10;
int main(){
ll n, a, b, i, j;
cin>>n>>a>>b;
vector<ll> v(n, 0);
for(i=0; i<n; i++){
cin>>v[i];
}
if(n==1){
cout<<v[0];
return 0;
}
a--, b--;
ll mn=inf;
for(i=0; i<(1<<(n-1)); i++){
ll s1=0;
for(j=0; j<n-1; j++){
if((i & (1<<j)) > 0){
s1++;
}
}
if(s1<a || s1>b) continue;
ll s=0, k=0;
for(j=0; j<n-1; j++){
s+=v[n-1-j];
if((i & (1<<j)) > 0){
k=(k|s);
s=0;
}
}
s+=v[0];
k=(k|s);
mn=min(k, mn);
}
cout<<mn;
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... |