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