이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include <bits/stdc++.h>
#define MAXN 67
using namespace std;
long long dp[MAXN],dpu[MAXN],p[MAXN];
long long count_tastiness(long long x, std::vector<long long> a)
{
while(a.size()<60) a.push_back(0);
int k=60;
p[0]=a[0];
for(long long i=1;i<k;i++) p[i]=p[i-1]+(a[i]<<i);
for(long long i=0;i<k;i++)
{
long long mx=(p[i]-(x<<i))/x;
dpu[i]=0;
if(p[i]>=(x<<i))
{
dpu[i]=1;
for(long long j=i;j>=0;j--) if((1LL<<j)&mx)
{
if(j!=0) dpu[i]+=dp[j-1];
long long nx=(p[j]-(x<<j))/x;
if(nx<mx) {dpu[i]+=dpu[j]; break;}
}
}
dp[i]=(i!=0)?dp[i-1]:0;
dp[i]+=dpu[i];
}
return dp[k-1]+1;
}
# | 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... |