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

#TimeUsernameProblemLanguageResultExecution timeMemory
418528oolimryPacking Biscuits (IOI20_biscuits)C++17
100 / 100
84 ms1324 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define sz(x) (int) (x).size() #define all(x) (x).begin(), (x).end() #define show(x) cerr << #x << " is " << x << endl; #define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl; #define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl; typedef long long lint; typedef pair<lint,lint> ii; map<lint,lint> memo; lint S[65]; lint dp(lint n){ ///number of good things <n if(n <= 0) return 0; if(n == 1) return 1; if(memo.find(n) != memo.end()) return memo[n]; lint a = 60; while(((1LL<<a)&(n-1))==0) a--; lint A = (1LL<<a); lint B = min(n,S[a]+1) - A; lint res = dp(A)+dp(B); memo[n] = res; return res; } lint count_tastiness(lint x, vector<lint> a){ for(lint i = 0;i < 60;i++) S[i] = 0; for(lint i = 0;i < sz(a);i++) S[i] += (a[i]<<i); for(lint i = 1;i < 60;i++) S[i] += S[i-1]; for(lint i = 0;i < 60;i++) S[i] /= x; memo.clear(); return dp(1LL<<60LL); }
#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...