PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000335. Tối đa hóa điện năng thấp nhất (Maximize the Minimum Powered City)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tối đa hóa điện năng thấp nhất (Maximize the Minimum Powered City)

Maximize the Minimum Powered City

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn cities indexed from 0 to n−1n-1 along a line, with aia_i stations at city i. A station at i contributes one unit of power to each city j satisfying ∣i−j∣≤r|i-j|\le r. Build exactly kk additional stations at any cities, possibly repeatedly at the same city. Maximize the minimum power among all cities.

Input

First line: n,r,kn,r,k. Second line: nn integers aia_i.

Output

Print the largest achievable minimum power.

Subtasks

  • Subtask 1 (20 points): 1≤n≤61\le n\le6; 0≤r<n0\le r<n; 0≤k≤50\le k\le5; 0≤ai≤1050\le a_i\le10^5.
  • Subtask 2 (30 points): 1≤n≤1051\le n\le10^5; r=0r=0; 0≤k≤1090\le k\le10^9; 0≤ai≤1050\le a_i\le10^5.
  • Subtask 3 (50 points): 1≤n≤1051\le n\le10^5; 0≤r<n0\le r<n; 0≤k≤1090\le k\le10^9; 0≤ai≤1050\le a_i\le10^5.

Examples

Input 1

5 1 2
1 2 4 5 0

Output 1

5

Explanation

Build both stations in city 1, obtaining powers 5,9,13,9,5. To reach 6 the two disjoint end regions would need at least 3 and 1 additional stations.

Input 2

4 0 3
4 4 4 4

Output 2

4

Explanation

Four additional stations would be needed to reach power 5 everywhere.