D - Outstanding Score Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300 点

問題文

高橋君のクラスでは、N 人の生徒がテストを受けました。各生徒 i(1 \leq i \leq N)のテストの点数は A_i です。

先生は、他の生徒と比べて特に優秀な成績を収めた生徒を表彰したいと考えています。具体的には、正の整数 K が与えられ、ある生徒の点数が自分以外の生徒の点数の平均値の K 倍以上であるとき、その生徒を「突出している」と呼ぶことにします。

より正確には、S = A_1 + A_2 + \cdots + A_N としたとき、生徒 i が「突出している」とは、

A_i \times (N - 1) \geq K \times (S - A_i)

を満たすことを言います。

ここで S - A_i は生徒 i 以外の N - 1 人の点数の合計です。N \geq 2 のとき、この不等式の両辺を N - 1 で割ると「A_i が自分以外の平均点の K 倍以上」という条件と同値になります。N = 1 のときは、両辺がともに 0 となるため、唯一の生徒は点数や K の値によらず常にこの条件を満たします。

「突出している」生徒の人数を求めてください。

制約

  • 1 \leq N \leq 2 \times 10^5
  • 1 \leq K \leq 10^9
  • 0 \leq A_i \leq 10^9(1 \leq i \leq N)
  • 入力はすべて整数である。

入力

N K
A_1 A_2 \ldots A_N
  • 1 行目には、生徒の人数を表す整数 N と、表彰の基準となる倍率を表す正の整数 K が、スペース区切りで与えられる。
  • 2 行目には、各生徒の点数を表す N 個の整数 A_1, A_2, \ldots, A_N が、スペース区切りで与えられる。

出力

「突出している」生徒の人数を 1 行で出力せよ。


入力例 1

5 2
10 2 3 1 4

出力例 1

1

入力例 2

4 3
5 5 5 5

出力例 2

0

入力例 3

10 5
100 3 2 1 4 2 3 1 2 2

出力例 3

1

入力例 4

20 2
50 50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

出力例 4

2

入力例 5

1 1000000000
0

出力例 5

1

Score : 300 pts

Problem Statement

In Takahashi's class, N students took a test. The test score of each student i (1 \leq i \leq N) is A_i.

The teacher wants to recognize students who achieved particularly excellent results compared to the other students. Specifically, given a positive integer K, a student is called "outstanding" if their score is at least K times the average score of all other students.

More precisely, let S = A_1 + A_2 + \cdots + A_N. Student i is "outstanding" if and only if:

A_i \times (N - 1) \geq K \times (S - A_i)

Here, S - A_i is the total score of the N - 1 students other than student i. When N \geq 2, dividing both sides of this inequality by N - 1 gives the equivalent condition "A_i is at least K times the average score of the other students." When N = 1, both sides become 0, so the sole student always satisfies this condition regardless of their score or the value of K.

Find the number of "outstanding" students.

Constraints

  • 1 \leq N \leq 2 \times 10^5
  • 1 \leq K \leq 10^9
  • 0 \leq A_i \leq 10^9 (1 \leq i \leq N)
  • All input values are integers.

Input

N K
A_1 A_2 \ldots A_N
  • The first line contains an integer N representing the number of students and a positive integer K representing the multiplier criterion for recognition, separated by a space.
  • The second line contains N integers A_1, A_2, \ldots, A_N representing each student's score, separated by spaces.

Output

Print the number of "outstanding" students in a single line.


Sample Input 1

5 2
10 2 3 1 4

Sample Output 1

1

Sample Input 2

4 3
5 5 5 5

Sample Output 2

0

Sample Input 3

10 5
100 3 2 1 4 2 3 1 2 2

Sample Output 3

1

Sample Input 4

20 2
50 50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Sample Output 4

2

Sample Input 5

1 1000000000
0

Sample Output 5

1