B - Height Comparison Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300 点

問題文

ある学校のクラスには N 人の生徒がいます。生徒には 1 から N までの出席番号が付けられています。

今日の体育の授業では、出席番号の昇順に 1 列に並んでいます。すなわち、出席番号 1 の生徒が列の先頭(最も前)にいて、出席番号 N の生徒が列の最後尾にいます。先生は、身長が T cm 以上の生徒を「高身長グループ」に指定しました。

並んでいる生徒のうち、自分より前(自分より出席番号が小さい位置)に、高身長グループに属し、かつ自分より厳密に身長が高い生徒が 1 人でもいる場合、その生徒は「見上げる生徒」と呼ばれます。見上げる生徒であるかの判定において、その生徒自身が高身長グループに属している必要はありません。また、列の先頭の生徒(出席番号 1)は、自分より前に誰もいないため、見上げる生徒にはなりません。

より形式的に述べると、生徒 i の身長を S_i cm としたとき、生徒 i(1 \leq i \leq N)が見上げる生徒であるための条件は以下の通りです:

  • 1 \leq j < i かつ S_j \geq T かつ S_j > S_i を満たす生徒 j が少なくとも 1 人存在する。

見上げる生徒の人数を求めてください。

制約

  • 1 \leq N \leq 10^6
  • 1 \leq T \leq 300
  • 1 \leq S_i \leq 300(1 \leq i \leq N)
  • 入力はすべて整数である。

入力

N T
S_1 S_2 \ldots S_N
  • 1 行目には、生徒の人数を表す整数 N と、高身長グループの閾値を表す整数 T(cm)が、スペース区切りで与えられる。
  • 2 行目には、出席番号 1 から N の各生徒の身長を表す整数 S_1, S_2, \ldots, S_N(cm)が、スペース区切りで与えられる。

出力

見上げる生徒の人数を 1 行で出力せよ。


入力例 1

5 170
180 160 175 150 165

出力例 1

4

入力例 2

4 180
160 165 170 175

出力例 2

0

入力例 3

10 165
150 170 160 180 155 165 190 140 200 195

出力例 3

5

入力例 4

20 160
155 162 158 170 165 150 168 172 160 145 180 175 153 167 159 190 140 185 163 171

出力例 4

14

入力例 5

1 100
150

出力例 5

0

Score : 300 pts

Problem Statement

A class in a certain school has N students. The students are assigned attendance numbers from 1 to N.

In today's physical education class, they are lined up in a single row in ascending order of attendance numbers. That is, the student with attendance number 1 is at the front of the line (the foremost position), and the student with attendance number N is at the end of the line. The teacher designated students whose height is at least T cm as the "tall group."

Among the students in the line, if there exists at least one student ahead of them (at a position with a smaller attendance number) who belongs to the tall group and is strictly taller than them, that student is called a "looking-up student." To determine whether a student is a looking-up student, the student themselves does not need to belong to the tall group. Also, the student at the front of the line (attendance number 1) cannot be a looking-up student, since there is no one ahead of them.

More formally, letting S_i cm be the height of student i, the condition for student i (1 \leq i \leq N) to be a looking-up student is as follows:

  • There exists at least one student j satisfying 1 \leq j < i, S_j \geq T, and S_j > S_i.

Find the number of looking-up students.

Constraints

  • 1 \leq N \leq 10^6
  • 1 \leq T \leq 300
  • 1 \leq S_i \leq 300 (1 \leq i \leq N)
  • All input values are integers.

Input

N T
S_1 S_2 \ldots S_N
  • The first line contains the integer N representing the number of students and the integer T (cm) representing the threshold for the tall group, separated by a space.
  • The second line contains the integers S_1, S_2, \ldots, S_N (cm) representing the heights of the students with attendance numbers 1 through N, separated by spaces.

Output

Output the number of looking-up students in a single line.


Sample Input 1

5 170
180 160 175 150 165

Sample Output 1

4

Sample Input 2

4 180
160 165 170 175

Sample Output 2

0

Sample Input 3

10 165
150 170 160 180 155 165 190 140 200 195

Sample Output 3

5

Sample Input 4

20 160
155 162 158 170 165 150 168 172 160 145 180 175 153 167 159 190 140 185 163 171

Sample Output 4

14

Sample Input 5

1 100
150

Sample Output 5

0