Game of Boxes
CodeChefOpen on judge ↗
Chef is playing a game where he has $N$ boxes each of size $Si$ ( $1$ ≤ $i$ ≤ $N$ ). To win the game, Chef has to select the maximum number of consecutive boxes such that the sum of the size of the largest and second-largest box is less than or equal to $M$ in that range. Help Chef to win the game by finding the maximum number of consecutive boxes such that the above condition is satisfied. N
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start