crates[i] = [left, side] means crate i has side length side and falls with its left edge at coordinate left, so it covers the horizontal span from left to left + side.
A crate falls straight down until it rests on the floor or on top of another crate, and then stays put. Crates that only touch along their vertical sides do not rest on each other.
After every drop, record the height of the tallest stack in the warehouse. Return the list of those heights.crates=[[2, 3], [4, 2], [9, 1]] → [3, 5, 5]
The first crate covers [2, 5] and is 3 tall. The second one ([4, 6]) overlaps it and lands on top at height 3, so its top is at 5. The third one falls to the floor on its own and the maximum stays 5.
crates=[[1, 4], [5, 4], [3, 2]] → [4, 4, 6]
The second crate only touches the side of the first one (spans [1, 5] and [5, 9]) and falls to the floor. The third one ([3, 5]) lands on the first: 4 + 2 = 6.
crates) ≤ 1000left ≤ 10⁸side ≤ 10⁶crates=[[2, 3], [4, 2], [9, 1]]
[3, 5, 5]
Run checks the first 3 tests in your browser. Submit checks all 106 tests on the server, hidden ones included.