Submission #932094

#TimeUsernameProblemLanguageResultExecution timeMemory
932094beabossPacking Biscuits (IOI20_biscuits)C++14
0 / 100
16 ms504 KiB
// Source: https://oj.uz/problem/view/IOI20_biscuits // #include "bits/stdc++.h" using namespace std; #define s second #define f first #define pb push_back typedef long long ll; typedef pair<ll, ll> pii; typedef vector<pii> vpii; typedef vector<ll> vi; #define FOR(i, a, b) for (ll i = (a); i<b; i++) bool ckmin(ll& a, ll b){ return b < a ? a = b, true : false; } bool ckmax(ll& a, ll b){ return b > a ? a = b, true : false; } ll count_tastiness(ll x, vector<ll> a) { vi dp(61); dp[0]=1; FOR(i, 1, 61) { ll mx = 0; ll alr = 0; ll tot = 0; for (ll j = i-1; j >= 0; j--) { tot += (1ll << j) * a[j]; // biscuits we have ll groups = (tot / x) >> j ; // stuff we can make here, wrt j mx = 2ll * mx + 1ll; // add extra 1 bit // cout << mx << endl; groups = min(groups, mx); groups++; // being empty // cout << i << ' ' << groups << ' ' << alr << endl; // assert(alr <= groups); dp[i] += dp[j] * max(groups - alr, 0ll); alr = max(groups, alr) * 2ll; } // break; } return dp[60]; }
#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...