# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
828229 | tomruk | 비스킷 담기 (IOI20_biscuits) | C++17 | 17 ms | 1236 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 <bits/stdc++.h>
using namespace std;
long long count_tastiness(long long x, vector<long long> a){
long long now = 0;
while(a.size() < 60)
a.push_back(0);
for(int i = 0;i<a.size();i++){
a[i] += now;
now = 0;
if(a[i] > x){
now = (a[i] - x)/2;
a[i] -= now * 2;
}
}
int k = a.size();
vector<long long> dp(k+1,0);
dp[0] = 1;
for(int i = 0;i<k;i++){
dp[i+1] = dp[i];
function<void(int,long long)> go = [&](int p,long long y) -> void{
long long coef = 1;
long long last = 0;
int tmp = p;
while(p > 0 && y < x * coef){
if(x * coef - y > 1e18)
break;
coef *= 2;
y *= 2;
p--;
if(y + a[p] >= x * coef){
last = x*coef - y;
y = x * coef;
}
else{
last = a[p];
y += a[p];
}
assert(y <= 1e18);
}
if(y < x * coef)
return;
dp[i + 1] += dp[p];
if(tmp != p)
go(p,a[p] - last);
};
go(i,a[i]);
}
return dp[k];
}
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... |