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

#TimeUsernameProblemLanguageResultExecution timeMemory
304361QAQAutoMatonPacking Biscuits (IOI20_biscuits)C++17
100 / 100
14 ms896 KiB
#include "biscuits.h" #include <algorithm> #include <vector> typedef long long ll; std::vector<long long> a; ll x; ll s[105],f[105]; bool chkmin(ll &a,ll b){return a>b?a=b,1:0;} ll dfs(int x,ll y){ chkmin(y,s[x]); if(!x){return std::min(y,s[x])+1;} if(y<s[x-1])return dfs(x-1,y); if(s[x-1]+(1ll<<x)<=y)return f[x-1]<<1; if(y>=(1ll<<x))return f[x-1]+dfs(x-1,y-(1ll<<x)); return f[x-1]; } long long count_tastiness(long long X, std::vector<long long> A) { while(A.size()<60)A.emplace_back(0); x=X;a=A; int k=a.size(); ll cur=0; for(int i=0;i<k;++i){ s[i]=std::min((cur+=a[i]<<i)/x,(1ll<<(i+1))-1); } f[0]=s[0]+1; for(int i=1;i<k;++i){ f[i]=dfs(i,(1ll<<(i+1))-1); } return f[k-1]; }
#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...