이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
using lint=long long;
using llint=__int128_t;
llint inf=1e20;
lint count_tastiness(lint X,vector<lint> a) {
llint x=X;
int n=a.size();
llint b[200]{};
for(int i=0;i<200;i++){
if(i<n)b[i]+=a[i];
if(x<b[i]){
b[i+1]=(b[i]-x)/2;
b[i]=x+((b[i]-x)&1);
}
//cerr<<lint(b[i])<<" ";
}//cerr<<"\n";
llint dp[200]{};
llint dppref[200]{};
for(int i=0;i<200;i++){
if(inf<(x<<i))break;
if(x<=b[i]){
if(i)dp[i]=dppref[i-1];
else dp[i]=1;
}else{
dp[i]=0;
llint neednow=x;
for(int j=i;0<=j;j--){
neednow-=b[j];
if(neednow<=0){
neednow=x+neednow;
if(neednow<=0){
dp[i]+=dppref[j];
break;
}else if(j)dp[i]+=dppref[j-1];
else dp[i]++;
}
neednow*=2;
if(inf<neednow)break;
}
}
dppref[i]=dp[i];
if(i)dppref[i]+=dppref[i-1];
else dppref[i]++;
}
llint ans=1;
for(int i=0;i<200;i++){
ans+=dp[i];
//if(i<5)cerr<<lint(dp[i])<<" "<<lint(dppref[i])<<" "<<i<<" dpval\n";
}
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... |