(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #398330

#TimeUsernameProblemLanguageResultExecution timeMemory
398330EverulePacking Biscuits (IOI20_biscuits)C++14
100 / 100
39 ms1296 KiB
#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)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:24:23: warning: unused variable 's' [-Wunused-variable]
   24 |         for(int j=i-1,s=0;j>=0;--j){
      |                       ^
#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...