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

#TimeUsernameProblemLanguageResultExecution timeMemory
303297jtnydv25Packing Biscuits (IOI20_biscuits)C++17
100 / 100
430 ms1016 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define ll long long ll count_tastiness(ll x, vector<ll> a) { int k = 60; a.resize(k); ll val = 0; vector<ll> prefixes(60); for(int i = 0; i < k; i++){ val += a[i] << i; // (prefix[i] + 2^i) * x <= val ll maxVal = val / x - (1LL << i) + 1; if(maxVal >= (1LL << i)) prefixes[i] = 1LL << i; else{ prefixes[i] = max(0LL, maxVal); } } map<ll, ll> dp; dp[1] = 1; for(int i = 1; i <= k; i++){ map<ll, ll> cp_dp = dp; dp.clear(); // dp[z] = # possible with the value of smallest i bits <= z for(auto it : prefixes){ ll v = it & ((1LL << i) - 1); if(v >> (i - 1) & 1){ ll t = v ^ (1LL << (i - 1)); dp[v] = cp_dp[1LL << (i-1)]; // ALL dp[v] += cp_dp[min(t, prefixes[i - 1])]; } else dp[v] = cp_dp[v]; } dp[1LL << i] = cp_dp[1LL << (i - 1)] + cp_dp[prefixes[i - 1]]; } return dp[1LL << k]; }
#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...