1297. Maximum Number of Ones

Problem

Given a matrix of 0s, set some cells to 1 such that every side-length-sideLength square has at most maxOnes ones. Maximize the total ones.

You are given a large matrix filled with 0s. You can set up to maxOnes cells to 1 in every sideLength x sideLength sub-square. Determine the maximum total number of 1s you can have in the entire matrix.

The constraint is that any square of size sideLength x sideLength can have at most maxOnes cells set to 1.

Examples
Input: [3,3,2,1]
Output: 4
Hints
Related Problems

1297. Maximum Number of Ones

Given a matrix of 0s, set some cells to 1 such that every side-length-sideLength square has at most maxOnes ones. Maximize the total ones.