rows × cols table starts out filled with zeros. Stamps are applied to it one after another: stamp stamps[k] = [a, b] adds one to every cell (x, y) with 0 ≤ x < a and 0 ≤ y < b, that is, to the a × b rectangle anchored at the top-left corner.
After all stamps are applied, find the largest number in the table and return how many cells hold it.
The table can be huge; there is no need to build it.rows=4, cols=5, stamps=[[3, 4], [2, 5]] → 8
Only the 2 × 4 corner rectangle is covered by both stamps: it holds 2, everything else is smaller. That is 8 cells.
rows=2, cols=3, stamps=[] → 6
No stamps were applied, so all 6 cells are zero, and all of them are the maximum.
rows=4, cols=5, stamps=[[3, 4], [2, 5]]
8
Run checks the first 3 tests in your browser. Submit checks all 113 tests on the server, hidden ones included.