Submission #918302

#TimeUsernameProblemLanguageResultExecution timeMemory
918302sq00Bali Sculptures (APIO15_sculpture)C++14
0 / 100
1 ms356 KiB
#include <bits/stdc++.h> using namespace std; void solve() { int n, a, b; cin >> n >> a >> b; vector<int>v(n + 1); for(int i = 1; i <= n; i++) { cin >> v[i]; } long long ans = 1e18; for(int i = 0; i < (1 << n); i++) { long long g = 0, sum = 0; for(int j = 0; j < n; j++) { sum += v[j + 1]; if(i & (1 << j)) { g |= sum; sum = 0; } } g |= sum; //cout << i << ": " << g << '\n'; int bits = __builtin_popcount(i) + (i & (1 << (n - 1)) == 0); if(a <= bits && bits <= b) ans = min(ans, g); } cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--) { solve(); } } /* 6 1 3 8 1 2 1 5 4 */

Compilation message (stderr)

sculpture.cpp: In function 'void solve()':
sculpture.cpp:23:64: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   23 |         int bits = __builtin_popcount(i) + (i & (1 << (n - 1)) == 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...