Submission #1095720

#TimeUsernameProblemLanguageResultExecution timeMemory
1095720NurislamBali Sculptures (APIO15_sculpture)C++17
9 / 100
190 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define int long long template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } const int N = (1<<18) +1, inf = 1e18+200; //int mod = 998244353; //int mod = 1000000007; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng) void solve(){ int n, a, b; cin >> n >> a >> b; vector<int> v(n); for(int &i:v)cin >> i; int ans = inf; for(int ms = 0; ms < (1<<(n-1)); ms++){ int cn = __builtin_popcount(ms)+1; if(cn < a || cn > b)continue; int tot = 0; int res = 0; for(int i = 0; i < n; i++){ res += v[i]; if((ms >> i) & 1){ tot |= res; res = 0; } } tot |= res; chmin(ans, tot); } cout << ans << '\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int tt = 1; //cin >> tt; while(tt--){ solve(); } }
#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...