Submission #131118

#TimeUsernameProblemLanguageResultExecution timeMemory
131118mlyean00Bali Sculptures (APIO15_sculpture)C++14
9 / 100
1087 ms504 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n, a, b; cin >> n >> a >> b; vector<ll> y(n); for (int i = 0; i < n; ++i) { cin >> y[i]; } vector<ll> pref(n + 1, 0); partial_sum(y.begin(), y.end(), pref.begin() + 1); ll ans = LLONG_MAX; for (ll i = 0; i < 1LL << (n - 1); ++i) { int set_bits = __builtin_popcount(i) + 1; if (set_bits < a || set_bits > b) continue; int last = 0; ll res = 0; for (int j = i; j; j -= j & -j) { int k = __builtin_ctz(j) + 1; res |= pref[k] - pref[last]; last = k; } res |= pref[n] - pref[last]; ans = min(ans, res); } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...