Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Ones

Maximum Number of Ones asks you to fill a binary matrix with as many ones as possible while every square subgrid of a given size contains at most a specified count.

Statement

Consider a binary matrix with dimensions width and height. You are also given an integer sideLength representing the side length of a square subgrid, and an integer maxOnes.

Return the maximum number of ones that can be placed in the matrix such that every square subgrid of size sideLength by sideLength contains at most maxOnes ones.

Constraints:

  • 1≤1 \leq width, height ≤100\leq 100

  • 1≤1 \leq sideLength ≤\leq width, height

  • 0≤0 \leq maxOnes ≤\leq sideLength ×\times sideLength

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Ones

Maximum Number of Ones asks you to fill a binary matrix with as many ones as possible while every square subgrid of a given size contains at most a specified count.

Statement

Consider a binary matrix with dimensions width and height. You are also given an integer sideLength representing the side length of a square subgrid, and an integer maxOnes.

Return the maximum number of ones that can be placed in the matrix such that every square subgrid of size sideLength by sideLength contains at most maxOnes ones.

Constraints:

  • 1≤1 \leq width, height ≤100\leq 100

  • 1≤1 \leq sideLength ≤\leq width, height

  • 0≤0 \leq maxOnes ≤\leq sideLength ×\times sideLength