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

#TimeUsernameProblemLanguageResultExecution timeMemory
500908InternetPerson10Packing Biscuits (IOI20_biscuits)C++17
100 / 100
10 ms1236 KiB
#include "biscuits.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; vector<ll> v; vector<ll> k; ll rec(int i, ll x) { // the last x are blocked, find total number of blocked if(i < (int)k.size()) { if(x <= k[i]) return v[i]; } if(i == 0) { if(v.size() == 0) return x; if(x == 1) return x; return v[i]; } if(x < ((ll)1 << (i))) { return v[i-1] + rec(i-1, x); } return ((ll)1 << (i)) + rec(i-1, x - ((ll)1 << (i))); } long long count_tastiness(long long x, std::vector<long long> a) { vector<ll>().swap(v); vector<ll>().swap(k); ll tot = 0; for(int i = 0; i < 61; i++) { if(x * ((ll)1 << (i+1)) > (ll)2000000000000000000) break; if(i == (int)a.size()) a.push_back(0); tot += ((ll)1 << i)*a[i]; if(tot >= x*((ll)1 << (i+1)) - 1) { v.push_back(rec(i, 0)); k.push_back(0); } else { v.push_back(rec(i, ((ll)1 << (i+1)) - tot/x - 1)); k.push_back(((ll)1 << (i+1)) - tot/x - 1); } } return ((ll)1 << v.size()) - v[v.size()-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...