이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
ll count_tastiness(ll x, vector<ll> a)
{
while (a.size() <= 60)
a.push_back(0);
ll s[61];
s[60] = 0;
for (int i = 59; i >= 0; i--)
{
s[i] = a[i] + s[i + 1] * 2;
if (s[i] >= 3 * x)
s[i] = 3 * x;
}
ll bent[60];
for (int i = 0; i < 60; i++)
{
ll lo = 0;
ll hi = x;
while (lo < hi)
{
ll d = (lo + hi) / 2;
ll sum = 2 * d;
bool ok = false;
for (int j = i; j < 60; j++)
{
sum /= 2;
sum += a[j];
if (sum >= x)
ok = true;
}
if (ok)
hi = d;
else
lo = d + 1;
}
bent[i] = lo;
}
function<ll(ll, int)>get = [&](ll d, int i)->ll
{
if (i == 60)
return d / x + 1;
if (d < bent[i])
return 1;
if (a[i] + d < x)
{
return get((d + a[i]) / 2, i + 1);
}
else
{
return get((d + a[i]) / 2, i + 1) + get((d + a[i] - x) / 2, i + 1);
}
};
return get(0, 0);
}
# | 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... |