Submission #334540

#TimeUsernameProblemLanguageResultExecution timeMemory
334540giorgikobPacking Biscuits (IOI20_biscuits)C++14
12 / 100
7 ms384 KiB
#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--){ 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]++; /* while(y >= 0 && k >= 0){ dp[i] += dp[k]; y -= x*(1LL<<k); cout << y << " "; cout << (1LL<<k) << " " << x*(1LL<<k) << " "; cout << endl; if(y < x && y >= 0){ dp[i]++; break; } while((1LL<<k)*x > y) k--; }*/ //cout << dp[i] << endl; //if(i < a.size())sum += a[i]*p; } //cout << endl; return dp[K]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...