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

#TimeUsernameProblemLanguageResultExecution timeMemory
310707apostoldaniel854Packing Biscuits (IOI20_biscuits)C++17
100 / 100
37 ms1024 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back using ll = long long; using lll = __int128_t; const int K = 60; const ll INF = 1e18; ll count_tastiness (ll _x, vector <ll> a) { a.resize (K); vector <lll> sum (1 + K); vector <lll> dp (1 + K); for (int i = 0; i < K; i++) sum[i + 1] = sum[i] + (a[i] << i); lll x = _x; dp[K] = 1; for (int i = K; i > 0; i--) { lll lb = sum[i], rb = sum[i]; for (int j = i - 1; j >= 0; 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); } } } 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...