이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll x;
vector<ll> a, sum;
map<ll, ll> dp;
ll solve(ll n) {
if (n <= 1) return n;
if (dp.find(n) != dp.end()) return dp[n];
int i = 63 - __builtin_clzll(n);
if ((1LL << i) == n) i--;
return dp[n] = solve(1LL << i) + solve(max(0LL, min(n, sum[i] / x + 1) - (1LL << i)));
}
long long count_tastiness(long long _x, std::vector<long long> _a) {
x = _x, a = _a;
sum.clear();
dp.clear();
while (a.size() < 60) a.push_back(0);
for (int i = 0; i < 60; i++) {
sum.push_back((sum.empty() ? 0LL : sum.back()) + a[i] * (1LL << i));
}
return solve(1LL << 60);
}
# | 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... |