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

#TimeUsernameProblemLanguageResultExecution timeMemory
1106452snpmrnhlolPacking Biscuits (IOI20_biscuits)C++17
100 / 100
57 ms1016 KiB
#include "biscuits.h" #include <bits/stdc++.h> #define int long long using namespace std; map <int,int> f; int s[61]; int x2; int solve(int nr){ if(f.find(nr) != f.end())return f[nr]; ///find answer int ans = 0; if(nr < 0)ans = 0; else if(nr == 0)ans = 1; else{ int nr2 = 0; while((1LL<<(nr2 + 1)) <= nr)nr2++; //cout<<nr<<' '<<(1ll<<nr2) - 1<<'\n'; ans+=solve((1ll<<nr2) - 1); ans+=solve(min(nr, s[nr2]/x2) - (1ll<<nr2)); } f[nr] = ans; return f[nr]; } long long count_tastiness(long long x, std::vector<long long> a) { f.clear(); x2 = x; int k = 60; int sum = 0; a.resize(60); for(int i = 0;i < k - 1;i++){ int nr = max(0ll,a[i] - x)/2*2; a[i]-=nr; a[i + 1]+=nr/2; } for(int i = 0;i < k;i++){ sum+=(1ll<<i)*a[i]; s[i] = sum; } return solve(sum/x); }
#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...