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

#TimeUsernameProblemLanguageResultExecution timeMemory
399639nvmdavaPacking Biscuits (IOI20_biscuits)C++17
100 / 100
93 ms1320 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define ll long long map<ll, ll> res; const ll MAX = 1'000'000'000'000'000'000; ll s[100]; ll find(ll r){ if(r < 0) return 0; if(r == 0) return 1; if(res.count(r)) return res[r]; int i = (int)floor(log2(r)); while((1LL << i ) > r ) --i; return res[r] = find((1LL << i) - 1) + find(min(r, s[i])- (1LL << i)); } long long count_tastiness(long long x, std::vector<long long> a) { res.clear(); while(a.size() < 60) a.push_back(0); for(int i = 0; i < 59; ++i){ ll t = max(0LL, (a[i] - x) / 2); a[i] -= t * 2; a[i + 1] += t; } a[59] = min(a[59], x + 1); ll t = 0; s[0] = a[0] / x; t = a[0] % x; for(int i = 1; i < 60; ++i){ s[i] = s[i - 1]; for(int j = i; j > 0; --j){ while(a[i] >= x){ s[i] = min(MAX, s[i] + (1LL << j)); a[i] -= x; } a[i] <<= 1; } while(a[i] >= x){ a[i] -= x; ++s[i]; } t += a[i]; while(t >= x){ t -= x; ++s[i]; } } return find(MAX); }
#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...