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>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
#include "biscuits.h"
const int K = 60;
long long count_tastiness(long long x, std::vector<long long> a) {
vector<ll>dp(K+1,0);
dp[0] = 1;
while(a.size() < K+5) a.pb(0);
vector<ll>gg(K+1,0),g(K+1,0);
for(int i = 0; i <= K; i++){
//if(a[i] > x) gg[i] = x*(1LL<<i), a[i] -= x, g[i] = x; else gg[i] = a[i]*(1LL<<i), g[i] = a[i], a[i] = 0;
//if(i) gg[i] += gg[i-1];
//a[i+1] += a[i]/2;
gg[i] = a[i] * (1LL<<i);
if(i) gg[i] += gg[i-1];
}
for(ll i = 1; i <= K; i++){
ll y = gg[i-1];
//cout << y << endl;
for(int k = i-1; k >= 0; k--){
if((1LL<<k) > (1LL<<K)/x) continue;
y = min(y,gg[k]);
if(y < (1LL<<k)*x) continue;
dp[i] += dp[k];
y -= (1LL<<k)*x;
//cout << y << " " << k << endl;
}
dp[i]++;
}
//cout << endl;
return dp[K];
}
# | 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... |