# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307726 | CodePlatina | Packing Biscuits (IOI20_biscuits) | C++14 | 2 ms | 452 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(k); b[0] = a[0];
for(int i = 1; i < k; ++i) b[i] = b[i - 1] + (a[i] << i);
for(int i = 0; i < k; ++i) b[i] /= y;
for(int i = 0; i < k; ++i) if(b[i] >= (1ll << i + 1)) b[i] = (1ll << i + 1) - 1;
vector<pll> V; V.push_back({(long long)1e18, 1});
for(int i = k - 1; 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... |