Submission #310681

#TimeUsernameProblemLanguageResultExecution timeMemory
310681apostoldaniel854Packing Biscuits (IOI20_biscuits)C++14
12 / 100
33 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back using ll = long long; const int K = 60; const ll INF = 1e18; bool check (ll x, ll p) { for (int i = 1; i <= p; i++) { x *= 2; if (x >= INF) return false; } return true; } ll count_tastiness (ll x, vector <ll> a) { a.resize (K); vector <ll> sum (1 + K); vector <ll> dp (1 + K); for (int i = 0; i < K; i++) sum[i + 1] = sum[i] + (a[i] << i); dp[K] = 1; for (int i = K; i > 0; i--) { ll lb = sum[i], rb = sum[i]; for (int j = i - 1; j >= 0; j--) { if (check (x, j)) { if (lb >= (x << j)) lb -= (x << j); if (rb >= sum[j]) { if (lb <= rb) dp[j] += dp[i] * (1 + (rb - max (lb, sum[j])) / (x << j)); rb -= (1 + (rb - sum[j]) / (x << j)) * (x << j); } } else { if (rb >= sum[j]) rb = 0; } } } return dp[0]; } /** int main () { int n; ll x; cin >> n >> x; vector <ll> v; for (int i = 1; i <= n; i++) { ll val; cin >> val; v.pb (val); } cout << count_tastiness (x, v) << "\n"; return 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...