# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1253447 | hoa208 | Bali Sculptures (APIO15_sculpture) | C++20 | 30 ms | 328 KiB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define pa pair<ll, ll>
#define fi first
#define se second
#define bit(mask, j) ((mask >> j) & 1)
#define t_test int t;cin >> t;while(t--)
const ll mod = 1e9 + 7;
const ll INF = 1e18;
inline void adm(ll &x){if(x>=mod)x%=mod;else if(x<0)x+=mod;}
//--------------------------------------------------------------------
const ll N = 2003;
ll w[N];
void hbmt() {
ll n, a, b;
cin >> n >> a >> b;
FOR(i, 1, n) {
cin >> w[i];
}
if(n > 20) return;
ll ans = INF;
FOR(mask, 0, (1 << n) - 1) {
if(!bit(mask, 0)) continue;
ll x = __builtin_popcount(mask);
if(x >= a && x <= b) {
ll res = 0, sum = 0;
FOR(i, 0, n - 1) {
if(bit(mask, i)) {
res |= sum;
sum = 0;
}
sum += w[i + 1];
}
res |= sum;
ans = min(ans, res);
}
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen("hbmt.inp", "r")) {
freopen("hbmt.inp", "r", stdin);
freopen("hbmt.out", "w", stdout);
}
// t_test
hbmt();
return 0;
}
Compilation message (stderr)
# | 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... |