# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334517 | giorgikob | Packing Biscuits (IOI20_biscuits) | C++14 | 19 ms | 876 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>
#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;
ll sum = a[0];
while(a.size() < K) a.pb(0);
for(ll i = 1; i <= K; i++){
if(((1LL<<i)-1) > (1LL<<K)/x) {
dp[i] = dp[i-1];
//cout << "aaaaaa" << endl;
//cout << dp[i] << " ";
continue;
}
ll b = ((1LL<<i)-1)*x;
ll y = 0;
for(ll j = i-1; j >= 0; j--){
y += min(a[j],(b-y)/(1LL<<j))*(1LL<<j);
}
//cout << y << endl;
int k = i-1;
while(y >= 0 && k >= 0){
dp[i] += dp[k];
y -= x*(1LL<<k);
if(y < x && y >= 0){
dp[i]++;
break;
}
while((1LL<<k)*x > y) k--;
}
//cout << dp[i] << " ";
//if(i < a.size())sum += a[i]*p;
}
//cout << endl;
return dp[K];
}
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... |