(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 #422391

#TimeUsernameProblemLanguageResultExecution timeMemory
422391TLP39Packing Biscuits (IOI20_biscuits)C++14
100 / 100
26 ms1324 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; long long k; long long ans[60],limit[60]; long long que(long long x,long long pos) { if(x>=limit[pos]) return ans[pos]; if(x<0) return 0; if(pos==0) return x+1; return que(x,pos-1)+que(x-(1ll<<pos),pos-1); } long long count_tastiness(long long x, std::vector<long long> a) { k=a.size(); if(k==1) return a[0]/x+1; limit[0]=a[0]; for(long long i=1;i<k;i++) limit[i]=limit[i-1]+(a[i]<<i); for(int i=0;i<k-1;i++) limit[i]=min((1ll<<(i+1))-1,limit[i]/x); limit[k-1]=limit[k-1]/x; long long ext=limit[k-1]>>(k-1); limit[k-1]%=(1ll<<(k-1)); ans[0]=limit[0]+1; for(long long i=1;i<k;i++) ans[i]=que(limit[i],i-1)+que(limit[i]-(1ll<<i),i-1); return ans[k-1]+ext*ans[k-2]; }
#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...