# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307729 | CodePlatina | Packing Biscuits (IOI20_biscuits) | C++14 | 54 ms | 1024 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.
#include "biscuits.h"
#include <vector>
#include <algorithm>
#include <utility>
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<long long, long long>
#define plll pair<long long, pll>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
#include <iostream>
using namespace std;
long long count_tastiness(long long y, vector<long long> a)
{
int k = a.size();
vector<long long> b(60); b[0] = a[0];
for(int i = 1; i < 60; ++i) b[i] = b[i - 1] + (i < k ? (a[i] << i) : 0);
for(int i = 0; i < 60; ++i) b[i] /= y;
for(int i = 0; i < 60; ++i) if(b[i] >= (1ll << i + 1)) b[i] = (1ll << i + 1) - 1;
vector<pll> V; V.push_back({(1ll << 61) - 1, 1});
for(int i = 59; i >= 0; --i)
{
vector<pll> _V;
for(auto x : V)
{
x.ff = min(x.ff, b[i]);
if(x.ff >= (1ll << i)) _V.push_back({(1ll << i) - 1, x.ss}), _V.push_back({x.ff - (1ll << i), x.ss});
else _V.push_back(x);
}
sort(_V.begin(), _V.end());
V.clear();
for(auto x : _V)
{
if(V.size() && V.back().ff == x.ff) V.back().ss += x.ss;
else V.push_back(x);
}
// cout << i << endl;
// for(auto x : V) cout << x.ff << ' ' << x.ss << endl;
}
return V[0].ss;
}
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... |