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 v vector
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
#define on(i,mask) ((bool)((1<<(i)) & (mask)))
int main(){
int N,A,B;
cin>>N>>A>>B;
v<ll> Y(N+1,0);
v<ll> psum(N+1, 0);
for(int i=1; i<=N; i++){
cin>>Y[i];
psum[i] = psum[i-1]+Y[i];
}
if(N<=20){
ll ans = 1e18;
for(int div = (1<<N); div<(1<<(N+1)); div++){
int g = 1;
int l=0;
ll res = 0;
for(int i=1; i<=N; i++){
if(i!=1 && on(i-2,div)!=on(i-1,div)){
g++;
res = res | (psum[i-1] - psum[l]);
l=i-1;
}
}
res = res | (psum[N]-psum[l]);
if(A<=g && g<=B) ans = min(ans, res);
}
cout<<ans<<endl;
}
}
# | 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... |