# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
398330 | Everule | Packing Biscuits (IOI20_biscuits) | C++14 | 39 ms | 1296 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"
using namespace std;
using ll = long long int;
long long count_tastiness(long long x, std::vector<long long> a) {
const int k = 61;
while(a.size() < k){
a.push_back(0);
}
vector<ll> dp(k);
vector<ll> pdp(k+1);
vector<ll> psum(k+1);
for(int i=1;i<=k;i++){
psum[i] = psum[i-1] + a[i-1] * (1ll<<(i-1));
}
for(int i=0;i<k;i++){
dp[i] = ((psum[i+1] / (1ll<<i) / x) != 0);
ll sum = psum[i+1] - (1ll<<i) * x;
ll mx = sum / x;
if(dp[i] == 0){
pdp[i+1] = pdp[i];
continue;
}
mx = min(mx, (1ll<<i) - 1);
for(int j=i-1,s=0;j>=0;--j){
if(mx & (1ll<<j)){
dp[i] += pdp[j];
sum = min(sum , psum[j+1]);
sum -= (1ll<<j) * x;
mx ^= (1ll<<j);
mx = min(mx, sum/x);
if(sum < 0) break;
dp[i]++;
}
}
pdp[i+1] = pdp[i] + dp[i];
}
//for(auto &x : pdp) cout<<x<<" ";
//cout<<"\n";
return pdp[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... |