Submission #834659

#TimeUsernameProblemLanguageResultExecution timeMemory
834659JohannPacking Biscuits (IOI20_biscuits)C++14
9 / 100
1121 ms1566712 KiB
#include "biscuits.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<ll> vi; typedef vector<vi> vvi; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() ll X; long long count_tastiness(long long _X, std::vector<long long> a) { X = _X; vector<__int128_t> S(sz(a) + 1, 0); __int128_t base = 1; for (int i = 0; i < sz(a); ++i) { S[i] += a[i] * base; S[i + 1] += S[i]; base *= 2; } ll ans = 1; vector<__int128_t> A(1, 0); base = 1; for (int i = 0; base * X <= S.back(); ++i) { ll size = sz(A); __int128_t bound = (i < sz(S)) ? S[i] : S.back(); for (int j = 0; j < size; ++j) { __int128_t y = A[j]; if ((y + base) * X <= bound) A.push_back(y + base), ++ans; } base *= 2; } 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...