# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
766381 | 2023-06-25T15:18:35 Z | 1ne | Bali Sculptures (APIO15_sculpture) | C++14 | 0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); long long n,a,b;cin>>n>>a>>b; vector<long long>arr(n); for (long long i = 0;i<n;++i){ cin>>arr[i]; } long long vv = 1e16; for (long long i = 0;i<(1<<n);++i){ long long v = 0; long long cnt = 0; for (long long j = 0;j<n;){ long long cur = (i & (1<<j)); long long k = j; long long ans = 0; while(k < n && (i & (1Ll<<k)) == cur){ ans+=arr[k]; ++k; } v|=ans; cnt++; j = k; } if (cnt >= a && cnt <= b){ vv = min(vv,v); } } cout<<vv<<'\n'; return 0; }