# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
805163 | alvingogo | Packing Biscuits (IOI20_biscuits) | C++14 | 2 ms | 340 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>
#pragma GCC optimize("Ofast")
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;
typedef long long ll;
ll count_tastiness(ll x, vector<ll> a) {
{
vector<ll> c(a.size()+1);
for(int i=0;i<a.size();i++){
c[i+1]=a[i];
}
a=c;
}
while(a.size()<=63){
a.push_back(0);
}
vector<ll> b=a;
int n=a.size();
for(int i=1;i<n;i++){
b[i]+=b[i-1]/2;
}
vector<ll> dp(n),pre(n),cost(n);
dp[0]=1;
pre[0]=1;
cost[0]=9e18;
for(int i=1;i<n;i++){
if(b[i]<x){
dp[i]=0;
pre[i]=pre[i-1];
cost[i]=-1;
continue;
}
if(a[i]>=x){
dp[i]=pre[i-1];
pre[i]=2*dp[i];
cost[i]=b[i]-x;
continue;
}
ll f=x-a[i];
for(int j=i-1;j>0;j--){
if(cost[j]>=0){
if(cost[j]/2>=f){
f*=2;
f-=a[j]-x;
if(j){
dp[i]+=pre[j-1];
}
}
}
}
dp[i]++;
pre[i]=pre[i-1]+dp[i];
cost[i]=b[i]-x;
}
return pre[n-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... |