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

#TimeUsernameProblemLanguageResultExecution timeMemory
578297jeroenodbPacking Biscuits (IOI20_biscuits)C++17
100 / 100
82 ms1336 KiB
#include "biscuits.h" #include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int mxN = 1e5+1, oo = 1e9; long long count_tastiness(long long x, std::vector<long long> a) { typedef __int128_t Int; map<Int,ll> dp; int k = a.size(); ll mx = *max_element(all(a)); const int K = k+__lg(mx)+2; vector<Int> s(K); for(int i=0;i<K;++i) { if(i) s[i]+=s[i-1]; if(i<k) s[i]+=Int(a[i])<<i; } auto solve = [&](auto&& self, Int n) -> ll { if(n<=0) return 0; if(n==1) return 1; if(dp.count(n)) return dp[n]; int i = 0; for(int j=64;j>=1;j/=2) { if(Int(1)<<(i+j)<n) i+=j; } return dp[n] = self(self,Int(1)<<i)+self(self,min(n,s[i]/x+1)-(Int(1)<<i)); }; return solve(solve,Int(1)<<K); }
#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...