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

#CT0000059. Trung bình đoạn (Segment Average)

Bài tập này chưa được xếp vào lộ trình.

Trung bình đoạn (Segment Average)

Segment Average

Version: Phuoc Hung OJ Extended

Problem Statement

Given an integer sequence A1,A2,…,ANA_1,A_2,\ldots,A_N and a positive integer KK. For every contiguous segment [L,R][L,R] of length at least KK, define

T(L,R)=∑i=LRAiR−L+1.T(L,R)=\frac{\sum_{i=L}^{R}A_i}{R-L+1}.

Find the largest integer XX for which there exists at least one segment [L,R][L,R] with R−L+1≥KR-L+1\ge K and T(L,R)≥XT(L,R)\ge X.

Input

The first line contains N,KN,K.

The second line contains A1,A2,…,ANA_1,A_2,\ldots,A_N.

Output

Print the largest valid integer XX.

Subtasks

  • Subtask 1 (20%): N≤300N\le300.
  • Subtask 2 (20%): K=1K=1.
  • Subtask 3 (30%): K=NK=N.
  • Subtask 4 (30%): 1≤K≤N≤2⋅1051\le K\le N\le2\cdot10^5, ∣Ai∣≤109|A_i|\le10^9.

Examples

Example 1

Input

5 2
1 12 -5 -6 50

Output

22

Explanation

Segment [4,5][4,5] has average (−6+50)/2=22(-6+50)/2=22, and no valid segment has a larger average.

Example 2

Input

4 3
-5 -2 -3 -4

Output

-3

Explanation

Segment [2,4][2,4] has average (−2−3−4)/3=−3(-2-3-4)/3=-3, hence X=−3X=-3.

Example 3

Input

5 3
10 1 1 1 10

Output

4

Explanation

The whole array has average 23/5=4.623/5=4.6. Since XX must be an integer, the largest possible value is 44.