/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 233 点
問題文
高橋君のクラスには高橋君以外に N 人の生徒がいます。先日行われたテストで、高橋君は X 点を取りました。i 番目 (1 \leq i \leq N) の生徒の点数は A_i 点です。
高橋君は自分より点数が高い生徒を見ると悔しく感じます。各生徒 i について、高橋君が感じる悔しさは A_i > X のとき A_i - X、そうでないとき 0 です。
高橋君が N 人の生徒全員に対して感じる悔しさの合計を求めてください。
制約
- 1 \leq N \leq 5 \times 10^5
- 0 \leq X \leq 100
- 0 \leq A_i \leq 100
- 入力はすべて整数
入力
N X A_1 A_2 \cdots A_N
- 1 行目には、高橋君以外の生徒の人数 N と高橋君の点数 X が、スペース区切りで与えられる。
- 2 行目には、N 人の生徒の点数 A_1, A_2, \ldots, A_N がスペース区切りで与えられる。
出力
高橋君が感じる悔しさの合計値を整数で 1 行に出力してください。
入力例 1
5 60 55 60 61 80 40
出力例 1
21
入力例 2
4 100 99 100 80 0
出力例 2
0
入力例 3
12 48 30 48 49 50 10 100 47 48 51 52 0 75
出力例 3
89
入力例 4
30 73 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
出力例 4
351
入力例 5
1 0 100
出力例 5
100
Score : 233 pts
Problem Statement
There are N students in Takahashi's class besides Takahashi himself. In a recent test, Takahashi scored X points. The i-th student (1 \leq i \leq N) scored A_i points.
Takahashi feels frustrated when he sees a student who scored higher than him. For each student i, the frustration Takahashi feels is A_i - X if A_i > X, and 0 otherwise.
Find the total frustration Takahashi feels toward all N students.
Constraints
- 1 \leq N \leq 5 \times 10^5
- 0 \leq X \leq 100
- 0 \leq A_i \leq 100
- All inputs are integers
Input
N X A_1 A_2 \cdots A_N
- The first line contains the number of students besides Takahashi N and Takahashi's score X, separated by a space.
- The second line contains the scores of the N students A_1, A_2, \ldots, A_N, separated by spaces.
Output
Print the total frustration Takahashi feels as an integer on a single line.
Sample Input 1
5 60 55 60 61 80 40
Sample Output 1
21
Sample Input 2
4 100 99 100 80 0
Sample Output 2
0
Sample Input 3
12 48 30 48 49 50 10 100 47 48 51 52 0 75
Sample Output 3
89
Sample Input 4
30 73 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Sample Output 4
351
Sample Input 5
1 0 100
Sample Output 5
100