# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
766376 | 2023-06-25T15:11:00 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); int n,a,b;cin>>n>>a>>b; vector<int>arr(n); for (int i = 0;i<n;++i){ cin>>arr[i]; } int vv = 0; for (int i = 0;i<(1<<n);++i){ int v = 0; for (int j = 0;j<n;){ int cur = (i & (1<<k)); int k = j; int ans = 0; while(k < n && (i & (1<<k)) == cur){ ans+=arr[k]; ++k; } v|=ans; cnt++; } if (cnt >= a && cnt <= b){ vv = max(vv,v); } } cout<<vv<<'\n'; return 0; }