

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 200 点
問題文
高橋君は N 科目のテストを受けます。各テストは K 点満点であり、点数はそれぞれ 0 以上の整数です。
高橋君は N-1 科目のテストを既に受けており、i 番目の科目のテストの点数は A_i 点でした。
高橋君の目標は、N 科目のテストの平均点を M 点以上にすることです。
高橋君が目標を達成するためには、最後のテストで最低何点取る必要があるか出力してください。
達成不可能である場合は、代わりに -1
を出力してください。
制約
- 2 \leq N \leq 100
- 1 \leq K \leq 100
- 1 \leq M \leq K
- 0 \leq A_i \leq K
- 入力中のすべての値は整数である。
入力
入力は以下の形式で標準入力から与えられる。
N K M A_1 A_2 ... A_{N-1}
出力
最後のテストでの必要最低点または -1
を出力せよ。
入力例 1
5 10 7 8 10 3 6
出力例 1
8
最後のテストで 8 点を取ると、(8+10+3+6+8)/5 = 7 より平均点は 7 点となり目標を達成できます。
入力例 2
4 100 60 100 100 100
出力例 2
0
最後のテストで 0 点を取っても目標を達成できます。
入力例 3
4 100 60 0 0 0
出力例 3
-1
もはや挽回は不可能です。
Score : 200 points
Problem Statement
Takahashi is taking exams on N subjects. The score on each subject will be an integer between 0 and K (inclusive).
He has already taken exams on N-1 subjects and scored A_i points on the i-th subject.
His goal is to achieve the average score of M points or above on the N subjects.
Print the minimum number of points Takahashi needs on the final subject to achieve his goal.
If the goal is unachievable, print -1
instead.
Constraints
- 2 \leq N \leq 100
- 1 \leq K \leq 100
- 1 \leq M \leq K
- 0 \leq A_i \leq K
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K M A_1 A_2 ... A_{N-1}
Output
Print the minimum number of points required on the final subject, or -1
.
Sample Input 1
5 10 7 8 10 3 6
Sample Output 1
8
If he scores 8 points on the final subject, his average score will be (8+10+3+6+8)/5 = 7 points, which meets the goal.
Sample Input 2
4 100 60 100 100 100
Sample Output 2
0
Scoring 0 points on the final subject still meets the goal.
Sample Input 3
4 100 60 0 0 0
Sample Output 3
-1
He can no longer meet the goal.