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>
#define pb push_back
#define int long long
#define mp make_pair
using namespace std;
const int inf = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
int32_t main(){
ios_base::sync_with_stdio(false), cin.tie();
int n, a, b;
cin>>n>>a>>b;
vector<int> arr(n);
for(int i = 0; i < n; i++){
cin>>arr[i];
}
int ans = inf;
for(int j = 1; j < (1 << n); j += 2){
int g = 0, val = 0, sum = 0;
for(int i = 0; i < n; i++){
if(j & (1 << i)){
val |= sum;
sum = 0;
g++;
}
sum += arr[i];
}
val |= sum;
if(g >= a && g <= b){
ans = min(ans, val);
}
}
cout<<ans<<endl;
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... |