HOLDIL - Editorial

PROBLEM LINKS:

Contest

Practice

DIFFICULTY:

Simple

EXPLAINATION

Problem [Water Buckets]:
In this problem for given total water S we have to find maximum N such that 1^2 + 2^2 + 3^2 + 4^2 +….+N^2 < = S
So we have formula of sum upto Kth no define Series_Sum(K) = K*(K+1)(2K+1)/6
So we can pre compute the Series_Sum(i) for all 1<= i <= 10^6 and can do binary search for the N[1 10^6] where Series_Sum(N) < = S .Same In Reference Solution.
Time Complexity: Big O(T*logS)

Reference Solution

Setter Solution

//