제출 #303870

#제출 시각아이디문제언어결과실행 시간메모리
303870tutisPacking Biscuits (IOI20_biscuits)C++17
9 / 100
1097 ms384 KiB
#include "biscuits.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; typedef long long ll; using namespace __gnu_pbds; #pragma GCC optimize ("O3") #pragma GCC target ("avx2") ll count_tastiness(ll x, vector<ll> a) { while (a.size() <= 60) a.push_back(0); ll s[61]; s[60] = 0; for (int i = 59; i >= 0; i--) { s[i] = a[i] + s[i + 1] * 2; if (s[i] >= 3 * x) s[i] = 3 * x; } ll bent[60]; for (int i = 0; i < 60; i++) { ll lo = 0; ll hi = x; while (lo < hi) { ll d = (lo + hi) / 2; ll sum = 2 * d; bool ok = false; for (int j = i; j < 60; j++) { sum /= 2; sum += a[j]; if (sum >= x) ok = true; } if (ok) hi = d; else lo = d + 1; } bent[i] = lo; } function<ll(ll, int)>get = [&](ll d, int i)->ll { if (i == 60) return d / x + 1; if (d < bent[i]) return 1; if (a[i] + d < x) { return get((d + a[i]) / 2, i + 1); } else { return get((d + a[i]) / 2, i + 1) + get((d + a[i] - x) / 2, i + 1); } }; return get(0, 0); }
#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...