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 <bits/stdc++.h>
using namespace std;
#define ll long long
map<ll, ll> d,s;
ll g(ll n, ll x)
{
if(n <= 0)return 0ll;
if(n == 1)return 1ll;
if(d.find(n) != d.end())return d[n];
ll i = 0;
while(i < 100){
if((1ll << i) < n && n <= (1ll << (i + 1)))break;
i++;
}
return d[n] = g((1ll << i), x) + g(min(n, 1 + s[i] / x) - (1ll << i), x);
}
long long count_tastiness(long long x, std::vector<long long> a) {
ll ans = 0;
while((int)a.size() < 100)a.push_back(0ll);
for(int i = 0; i < 100; i++){
s[i] = s[i - 1] + (1ll << i) * a[i];
}
ans += g((1ll << 60), x);
d.clear();
s.clear();
return ans;
}
# | 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... |