Submission #112537

#TimeUsernameProblemLanguageResultExecution timeMemory
112537TuGSGeReLBali Sculptures (APIO15_sculpture)C++17
0 / 100
1078 ms512 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define mp make_pair #define pub push_back #define pob pop_back() #define ss second #define ff first #define mt make_tuple #define pof pop_front() #define fbo find_by_order #define ook order_of_key #define lb lower_bound #define ub upper_bound typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; using pll = pair <ll, ll>; using pii = pair <int, int>; ll n, a, b, x[1001], ans = 1e9; int main () { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> a >> b; for (int i = 1; i <= n; i++) cin >> x[i]; for (int i = 0; i < ( 1 << n ); i++ ) { ll s = 0, k = 0, res = 0, seg = 1; for (int j = 0; j < n; j++) { if ( (i & (1 << j)) ) { if ( k == 0 ) { k = 1; res |= s; s = x[j + 1]; seg++; } else { s += x[j + 1]; } } else { if ( k == 0 ) s += x[j + 1]; else { res |= s; s = x[j + 1]; k = 0; seg++; } } } res |= s; if (seg <= b && seg >= a ) ans = min(ans, res); } cout << ans; }
#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...