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

#TimeUsernameProblemLanguageResultExecution timeMemory
303278ecnerwalaPacking Biscuits (IOI20_biscuits)C++17
100 / 100
29 ms1016 KiB
#include "biscuits.h" #include <vector> #include <iostream> long long count_tastiness(long long X, std::vector<long long> A) { auto get_A = [&](int i) { return i < int(A.size()) ? A[i] : 0; }; std::vector<long long> len(121); len[0] = 1; std::vector<long long> max_elt(121); // floor of the max element max_elt[0] = 0; for (int i = 0; i < 120; i++) { max_elt[i+1] = (get_A(i) + max_elt[i]) / 2; len[i+1] = 0; long long cutoff = 0; for (int j = i; j >= 0; j--) { cutoff *= 2; cutoff -= get_A(j); if (max_elt[j] >= cutoff + X) { len[i+1] += len[j]; cutoff += X; } cutoff = std::max(cutoff, 0ll); } len[i+1]++; // the final 0 } return len.back(); } // poss_carry = [0] // for i in range(120): // poss_carry = [a[i] + v for v in poss_carry] // poss_carry = [v - x for v in poss_carry if v >= x] + poss_carry // poss_carry = [v / 2 for v in poss_carry] // assert max(poss_carry) - min(poss_carry) < x // mem[i+1] = poss_carry // return len(poss_carry)
#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...