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
int arr[2001];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,a,b;
cin >> n >> a >> b;
for(int i=0;i<n;i++)cin>>arr[i];
int ans = INT64_MAX;
for(int subset=0;subset<(1<<(n-1));subset++){
if(__builtin_popcount(subset)!=(b-1))continue;
int curr = 0;
int currsum = 0;
for(int i=0;i<n-1;i++){
currsum+=arr[i];
if(subset&(1<<i)){
curr|=currsum;
currsum=0;
}
}
curr|=currsum+arr[n-1];
ans = min(ans,curr);
}
cout << ans << '\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... |