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

#TimeUsernameProblemLanguageResultExecution timeMemory
371334pit4hPacking Biscuits (IOI20_biscuits)C++14
100 / 100
30 ms1408 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; const ull INF = 2e18+1; ll count_tastiness(ll _x, vector<ll> _a) { ull x = _x; int k = _a.size(); vector<ull> a(k+60, 0); for(int i=0; i<k; ++i) a[i] = _a[i]; k+=60; vector<ull> dp(k), dp0(k), pref(k); pref[0] = a[0]; for(int i=1; i<k; ++i) { pref[i] = pref[i-1]/2 + a[i]; } for(int i=0; i<k; ++i) { if(i>0) { dp0[i] = dp[i-1]; } else { dp0[i] = 1; } ull sum = 0; dp[i] = 1; for(int j=i; j>=0; --j) { if(pref[j] >= x + sum) { dp[i] += dp0[j]; if(sum < INF && sum + x < INF) { sum += x; if(a[j] > sum) sum = 0; else sum -= a[j]; sum *= 2; } else { sum = INF; } } else { if(a[j] > sum) sum = 0; else sum -= a[j]; if(sum < INF) sum *= 2; else sum = INF; } } } return dp[k-1]; }
#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...