# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824875 | fatemetmhr | Packing Biscuits (IOI20_biscuits) | C++17 | 1083 ms | 49080 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Be name khoda //
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << "(" << #x << "):" << x << endl;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long ll;
const int maxn5 = 1e6 + 10;
pair <ll, ll> toadd[maxn5];
priority_queue <pair<ll, ll>> av;
long long count_tastiness(long long x, std::vector<long long> a) {
int k = 60;
while(a.size() < k)
a.pb(0);
ll ans = 1;
int ind = 0;
while(ind < k){
if(a[ind] >= x + 2){
a[ind + 1] += (a[ind] - x) / 2;
a[ind] -= ((a[ind] - x) / 2) * 2;
}
//if(a[ind]) cout << ind << ' ' << a[ind] << endl;
ind++;
}
k = a.size();
while(av.size())
av.pop();
av.push({0, 1});
ll add = 0;
for(int i = 0; i < k; i++){
ll tagh = (1ll << i);
int pt = 0;
while(av.size() && (av.top().fi + add) / tagh + a[i] >= x){
toadd[pt] = av.top();
av.pop();
toadd[pt + 1] = toadd[pt];
pt++;
ans += toadd[pt].se;
toadd[pt].fi -= tagh * x;
pt++;
}
while(pt > 0){
av.push(toadd[pt - 1]);
pt--;
}
add += a[i] * tagh;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |