# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303919 | Pajaraja | Packing Biscuits (IOI20_biscuits) | C++17 | 14 ms | 896 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>
#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)
{
int k=0;
while((x<<k)<=3000000000000000000LL)
{
k++;
if(k-1==a.size()) a.push_back(0);
}
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))
{
if(mx>=(1LL<<i)) dpu[i]=(i!=0)?dp[i-1]:1;
else
{
bool fas=false;
for(long long j=i-1;j>=0;j--) if((1LL<<j)&mx)
{
dpu[i]+=(j!=0)?dp[j-1]:1;
long long nx=(p[j]-(x<<j))/x;
if(p[j]<(x<<j)) {fas=true; break;}
mx^=(1LL<<j);
if(nx<mx) {dpu[i]+=dpu[j]; fas=true; break;}
}
if(!fas) dpu[i]++;
}
}
dp[i]=(i!=0)?dp[i-1]:1;
dp[i]+=dpu[i];
}
return dp[k-1];
}
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... |