Submission #638693

#TimeUsernameProblemLanguageResultExecution timeMemory
638693slimePacking Biscuits (IOI20_biscuits)C++14
0 / 100
1085 ms340 KiB
#include "biscuits.h" #include "bits/stdc++.h" using namespace std; bool check(long long x, long long y, std::vector<long long> a) { int k = a.size(); for(int i=0; i<x; i++) { long long w = y; for(int j=k-1; j>=0; j--) { long long nd = w / (1ll << j); nd = min(nd, a[j]); a[j] -= nd; w -= nd * (1ll << j); } if(w) return 0; } return 1; } long long count_tastiness(long long x, std::vector<long long> a) { long long nxt = -1; long long mul = 1; long long ans = 1; while(1) { nxt++; if(!check(x, nxt * mul, a)) { // find next perfect power, e.g. 6 -> 8 long long lg = 64 - __builtin_clzll(nxt) - 1; lg = mul * (1ll << (lg + 1)); mul = lg; // if [0, 9] ok, 10 not ok, ans *= nxt if(nxt == 1) break; ans *= nxt; nxt = 0; } } ans *= nxt; 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...