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

#PS0000196. Đoạn dài nhất có trung bình không nhỏ hơn K (Longest Subarray With Mean At Least K)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Đoạn dài nhất có trung bình không nhỏ hơn K (Longest Subarray With Mean At Least K)

Longest Subarray With Mean At Least K

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn integers and an integer KK, find the maximum length of a nonempty consecutive interval [l,r][l,r] whose arithmetic mean is at least KK, equivalently ∑i=lrai≥K(r−l+1)\sum_{i=l}^{r}a_i\ge K(r-l+1). Print 0 if no such interval exists.

Input

The first line contains n,Kn,K. The second contains exactly nn integers aia_i.

Output

Print the maximum length, or 0 if none exists.

Subtasks

  • Subtask 1 (20 points): 1≤n≤5001\le n\le 500; −109≤ai,K≤109-10^9\le a_i,K\le10^9.
  • Subtask 2 (30 points): 1≤n≤2000001\le n\le 200000; −109≤ai,K≤109-10^9\le a_i,K\le10^9; ai≥Ka_i\ge K.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000; −109≤ai,K≤109-10^9\le a_i,K\le10^9.

Example 1

Input

5 5
7 2 6 1 8

Output

3

Explanation

Interval [3,5] sums to 15, mean 5. The two length-four sums are 16 and 17; the full sum is 24, so no longer interval qualifies.

Example 2

Input

3 0
-3 -2 -1

Output

0

Explanation

Every interval has negative sum.