제출 #303592

#제출 시각아이디문제언어결과실행 시간메모리
303592JooDdae비스킷 담기 (IOI20_biscuits)C++17
0 / 100
1 ms384 KiB
#include<bits/stdc++.h> #include "biscuits.h" using namespace std; using ll = long long; ll count_tastiness(ll x, vector<ll> a) { ll ans = 1; priority_queue<pair<ll, ll>> pq; for(int i=a.size()-1;i>=0;i--){ ll u = 1ll << i; if(a[i]){ ll p = 0; queue<pair<ll, ll>> q; while(!pq.empty() && pq.top().first > u){ auto [x, y] = pq.top(); pq.pop(); ll s = min(x / u, a[i] + 1); p += (s - 1) * y; ans += (s - 1) * y; if(x > u * s) q.push({x - u * s, y}); else p += y; } while(!q.empty()) pq.push(q.front()), q.pop(); ans += a[i]; pq.push({u, a[i] + p}); } } // while(!pq.empty()) printf("%lld %lld\n",pq.top().first,pq.top().second), pq.pop(); return 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...