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

#TimeUsernameProblemLanguageResultExecution timeMemory
397191rocks03Packing Biscuits (IOI20_biscuits)C++14
100 / 100
38 ms1292 KiB
//#pragma GCC target("avx2") //#pragma GCC optimization("O3") //#pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int N = 60; ll x; vector<ll> a; unordered_map<ll, ll> memo; ll f(ll n){ if(n == 0) return 1; if(memo[n]) return memo[n]; ll& ans = memo[n]; int hbit = 63 - __builtin_clzll(n); ll max_y = min(a[hbit] / x, n); if(max_y >= (1ll << hbit)){ ans += f(max_y - (1ll << hbit)); } ans += f((1ll << hbit) - 1); return ans; } long long count_tastiness(long long X, vector<long long> A){ while(SZ(A) < N) A.pb(0); rep(i, 0, N) A[i] = A[i] * (1ll << i); rep(i, 1, N) A[i] += A[i - 1]; x = X; a = A; memo.clear(); return f(a.back()); }
#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...