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

#TimeUsernameProblemLanguageResultExecution timeMemory
359333JasiekstrzPacking Biscuits (IOI20_biscuits)C++17
100 / 100
38 ms1388 KiB
#include "biscuits.h" #include<bits/stdc++.h> #define fi first #define se second using namespace std; const int K=60; vector<long long> ans(K); vector<long long> s(K); long long _x; inline long long cc(int i) { long long xd=(s[i]/_x); if(xd>=(1LL<<(i+1))) return (1LL<<(i+1))-1; return xd; } long long f(int i,long long l) { if(i==0) { if(l>0 && cc(i)>0) return 2; return 1; } if((l&(1LL<<i)) && (cc(i)&(1LL<<i))) return ans[i-1]+f(i-1,min(l,cc(i))^(1LL<<i)); return f(i-1,min(l,cc(i))); } long long count_tastiness(long long x,vector<long long> a) { _x=x; while(a.size()<K) a.push_back(0); s[0]=a[0]; for(int i=1;i<K;i++) s[i]=(s[i-1]+(1LL<<i)*a[i]); for(int i=0;i<K;i++) ans[i]=f(i,(1LL<<(i+1))-1); //cerr<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<"\n"; return ans[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...