width × height, and every cell holds 0 or 1. Every square block of size side × side must contain at most limit ones.
Return the largest number of ones the whole grid can contain.width=4, height=3, side=2, limit=1 → 4
Place ones where both coordinates are even: (0, 0), (0, 2), (2, 0), (2, 2). Every 2 × 2 square holds at most one of them, giving 4 ones.
width=3, height=3, side=3, limit=9 → 9
The limit allows the whole 3 × 3 grid to be filled with ones.
width=5, height=5, side=2, limit=0 → 0
width=4, height=3, side=2, limit=1
4
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.