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

#TimeUsernameProblemLanguageResultExecution timeMemory
5685032fat2codePacking Biscuits (IOI20_biscuits)C++17
100 / 100
42 ms1308 KiB
#include "biscuits.h" #include <bits/stdc++.h> #define fr first #define sc second #define all(s) s.begin(), s.end() #define int long long using namespace std; const int nmax = 60; int k, sum[nmax], total, X; unordered_map<int, int>prec; int calculate(int n){ // cout << n << '\n'; if(prec.count(n)){ return prec[n]; } else if(n < 0LL) return 0LL; else{ int largestbit = 0; while((1LL << (largestbit + 1LL)) <= n){ ++largestbit; } prec[n] = calculate((1LL << largestbit) - 1LL) + calculate(min(n, sum[largestbit] / X) - (1LL << largestbit)); return prec[n]; } } int count_tastiness(int x, vector<int> a) { total = 0; X = x; prec.clear(); k = (int)a.size(); for(int i=0;i<k;i++) sum[i] = 0; for(int i=0;i<k;i++){ total += (a[i] * (1LL << i)); sum[i] += (a[i] * (1LL << i)); if(i) sum[i] += sum[i - 1]; } for(int i=k;i<60;i++) sum[i] = sum[i - 1]; prec[0] = 1; int ans = calculate(total / x); return ans; }
#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...