# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
424200 | Apiram | Packing Biscuits (IOI20_biscuits) | C++14 | 18 ms | 1328 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>
using namespace std;
long long count_tastiness(long long x, std::vector<long long> a) {
int64_t counts =1;
/*int64_t covered = 0;
for (int64_t i =0;i<n;++i){
int64_t temp = pow(2,i)*arr[i];
counts+=(covered - temp)/pow(2,i);
covered = max(covered,temp);
}*/
vector<int64_t>arr(61,0);
int64_t sum=0;
for (int64_t i =0;i<a.size();++i){arr[i]=a[i];sum+=1LL<<i;}
for (int64_t i =1;i<=60;++i){
arr[i]+=arr[i-1]/2;
}
vector<int64_t>dp(62,0);
dp[0]=1;
a.resize(62,0);
for (int i =0;i<60;++i){
if (arr[i]<x){
dp[i+1]=dp[i];
continue;
}
int64_t temp =(arr[i]-a[i])/2;
dp[i+1]+=dp[i];
int64_t temp2 = max(x - a[i],0LL)*2;
for (int j =i-1;j>=0;--j){
if (arr[j]-temp2>=x){dp[i+1]+=dp[j];
temp2=max(0LL,x-a[j]+temp2)*2;
}
else temp2=max(0LL,temp2-a[j])*2;
//how to check whether it is possible to get this bit ??
}
if (temp2==0){
dp[i+1]++;
}
}
return dp[60];
}
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... |