Tap here to switch tabs
Problem
Submissions

Problem: Maximize the Minimum Powered City

Try to solve the Maximize the Minimum Powered City problem.

Statement

You are given a 00 indexed integer array stations of length n, where stations[i] denotes the number of power stations in the iextthi^{ ext{th}} city.

Each power station provides power to every city within a distance of r. That is, a power station at city j provides electricity to city i if ∣i−j∣≤|i - j| \leq r.

The total power of a city is the sum of all power stations that can provide electricity to it.

You are also given two integers r and k. You may construct at most k additional power stations in any of the cities.

Return the maximum possible minimum power among all cities after optimally adding at most k additional power stations.

Constraints:

  • n == stations.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq stations[i] ≤105\leq 10^5

  • 0≤0 \leq r ≤\leq n −1- 1

  • 0≤0 \leq k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximize the Minimum Powered City

Try to solve the Maximize the Minimum Powered City problem.

Statement

You are given a 00 indexed integer array stations of length n, where stations[i] denotes the number of power stations in the iextthi^{ ext{th}} city.

Each power station provides power to every city within a distance of r. That is, a power station at city j provides electricity to city i if ∣i−j∣≤|i - j| \leq r.

The total power of a city is the sum of all power stations that can provide electricity to it.

You are also given two integers r and k. You may construct at most k additional power stations in any of the cities.

Return the maximum possible minimum power among all cities after optimally adding at most k additional power stations.

Constraints:

  • n == stations.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq stations[i] ≤105\leq 10^5

  • 0≤0 \leq r ≤\leq n −1- 1

  • 0≤0 \leq k ≤109\leq 10^9