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

#TimeUsernameProblemLanguageResultExecution timeMemory
392326johuthaPacking Biscuits (IOI20_biscuits)C++17
100 / 100
19 ms1332 KiB
#include "biscuits.h" #include <iostream> #define int long long #define lint __int128 using namespace std; int count_tastiness(int x, vector<int> a) { const int m = 64; vector<int> pref_dp(m); vector<int> dp(m); vector<lint> avs(m); dp[0] = 1; a.resize(m); avs[0] = 0; lint pw = 1; for (int i = 0; i < m - 1; i++, pw *= 2) { avs[i + 1] = avs[i] + pw * (lint)a[i]; } // cerr << 0 << " " << dp[0] << "\n"; pw = 1; for (int i = 1; i < m; i++, pw *= 2) { pref_dp[i] = dp[i - 1] + pref_dp[i - 1]; if (avs[i] < pw*x) continue; lint b = avs[i] - pw*x; lint np = pw / 2; // cerr << "Starting " << i << " with " << avs[i] << ", after subtracting " << b << "\n"; for (int j = i - 1; j >= 0; j--, np /= 2) { b = min(b, avs[j]); // cerr << " -> " << j << " " << b << " " << np << "\n"; if (b >= np * x) { dp[i] += pref_dp[j]; b -= np*x; } } if (b >= 0) dp[i]++; // cerr << i << " " << dp[i] << "\n"; } return dp[m - 1] + pref_dp[m - 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...