# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
400772 | REALITYNB | Packing Biscuits (IOI20_biscuits) | C++17 | 1083 ms | 332 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 <bits/stdc++.h>
#include "biscuits.h"
#define int long long
using namespace std;
int sub1(int k , vector<int> a){
int ans = 0 ;
int n = 60 ;
while(a.size()!=n+1) a.push_back(0) ;
for(int target=0;target<=100000;target++){
vector<int>b=a;
bool flg =1 ;
for(int i=0;i<n;i++){
if((1<<i)&target){
if(b[i]<k){
flg=0 ;
break ;
}
b[i]-=k;
b[i+1]+=b[i]/2 ;
}
else b[i+1]+=b[i]/2 ;
}
ans+=flg;
}
return ans ;
}
int count_tastiness(int k,vector<int> a){
if(k!=1)
return sub1(k,a) ;
int n =120 ;
while(n!=a.size()) a.push_back(0) ;
vector<int> dp(n+1);
dp[n]=1;
for(int i=n-1;i>-1;i--){
int sum = 0 ;
vector<int> b=a;
int stop = i+1;
for(int j=i;j<n;j++){
if(b[j]>1){
b[j+1]+=b[j]/2;
if(b[j]&1) b[j]=1;
else b[j]=0;
stop=j+2;
}
else break ;
}
if(a[i]==0) {
dp[i]+=dp[i+1] ;
continue ;
}
vector<int> in ;
for(int j=i;j<stop;j++) if(b[j]) in.push_back(j) ;
for(int j=1;j<in.size();j++)
dp[i]+=dp[stop]*(1LL<<(in[j-1]-i));
dp[i]+=dp[stop];
dp[i]+=dp[stop]*(1LL<<(in.back()-i)) ;
}
return dp[0] ;
}
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... |