101511: [AtCoder]ABC151 B - Achieve the Goal

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

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.

Input

题意翻译

高桥要参加 $N$ 门科目的考试,每门考试的满分都是 $K$ 分。他给自己定了 $N$ 门平均分上 $M$ 分的目标(含 $M$ 分)。现在高桥已经完成了 $N-1$ 门科目的考试,他在第 $i$ 门考试中的得分为 $A_i$ 分。现在高桥给出了你 $N,K,M$ 以及所有的 $A_i$ ,想请你求出他为了达成目标,在最后的测试中至少应该得多少分。如果他不可能完成目标,输出-1.

加入题单

上一题 下一题 算法标签: