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

#TimeUsernameProblemLanguageResultExecution timeMemory
534324benson1029Packing Biscuits (IOI20_biscuits)C++14
100 / 100
39 ms1320 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; int k; long long X; vector<long long> pref; long long ans[65]; int logb2(long long x) { int cnt = 0; while(x>1) { cnt++; x/=2; } return cnt; } long long findans(long long x) { if(x<=0) { return 0; } if(x==1) { return 1; } int LOG = logb2(x-1); int LOG1 = logb2(x); if(LOG != LOG1 && ans[LOG1]!=-1) { return ans[LOG1]; } long long v = findans(1LL<<LOG) + findans(min(x, 1+pref[LOG]/X) - (1LL<<LOG)); if(LOG != LOG1) { ans[LOG1] = v; } return v; } long long count_tastiness(long long x, std::vector<long long> a) { k = a.size(); X = x; pref.resize(61); a.resize(61); for(int i=0; i<=61; i++) ans[i] = -1; for(int i=k; i<61; i++) { a[i] = 0; } for(int i=0; i<61; i++) { pref[i] = (1LL<<i) * a[i]; if(i) pref[i] += pref[i-1]; } return findans(1LL<<61); }
#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...