이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
ll X;
ll base[64];
vector<ll> S;
map<ll, ll> G;
ll g(ll n)
{
if (n <= 1)
return max(0LL, n);
if (G.find(n) != G.end())
return G[n];
int power = (lower_bound(base, base + 62, n) - base) - 1;
return G[n] = g(1LL << power) + g(min(n, S[min(power, sz(S) - 1)] / X + 1) - (1LL << power));
}
long long count_tastiness(long long _X, std::vector<long long> a)
{
X = _X;
G.clear();
S.assign(sz(a) + 1, 0);
base[0] = 1;
for (int i = 0; i < 62; ++i)
base[i + 1] = 2 * base[i];
for (int i = 0; i < sz(a); ++i)
{
S[i] += a[i] * base[i];
S[i + 1] += S[i];
}
return g(S.back() / X + 1);
}
# | 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... |