Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Minimum Sensors to Cover Grid

XPChallenge Points: 20
levelLevel: Medium

You are given a rectangular battlefield represented as an n × m grid and an integer k.
A tower placed on cell (r, c) can cover all cells whose Chebyshev distance from (r, c) is at most k.
The Chebyshev distance between two cells (r1, c1) and (r2, c2) is defined as:
distance=max(∣r1−r2∣,∣c1−c2∣)
Your task is to find the minimum number of towers required to cover every cell in the battlefield grid.

Example 1:

Input: n = 7 m = 5 k = 1

Output: 6

Example 2:

Input: n = 6 m = 6 k = 2

Output: 4

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result