Submission #308302

#TimeUsernameProblemLanguageResultExecution timeMemory
308302bruce_testPacking Biscuits (IOI20_biscuits)C++14
9 / 100
1138 ms721128 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define lc (rt<<1) #define rc (rt<<1|1) #define pb push_back #define cl(a, b) memset(a, b, sizeof(a)) typedef long long ll; typedef pair<int, int> pi; typedef pair<int, pi> pii; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pi> vii; typedef vector<pii> viii; const int inf = 0x3F3F3F3F; const ll infl = 0x3F3F3F3F3F3F3F3FLL; const int mod = 1e9 + 7, LOG=60; ll cnt, psa[LOG]; unordered_map<ll, ll> mp; ll fun(ll x){ if(x < 0) return 0; if(x == 0) return 1LL; if(mp.count(x)) return mp[x]; int p = 63 - __builtin_clzll(x); mp[x] = fun((1<<p)-1) + fun(min(x, psa[p]/cnt) - (1<<p)); return mp[x]; } ll count_tastiness(ll x, vl a){ a.resize(LOG); cnt = x; mp.clear(); psa[0] = a[0]; for(int i=1; i<LOG; i++) psa[i] = psa[i-1] + a[i]*(1LL<<i); return fun((1LL<<LOG) - 1); } //int main(){ // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); // vl a = {5, 2, 1}; // cout << count_tastiness(3, a) << endl; //}
#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...