#abc321b. B - Cutoff
B - Cutoff
Score : points
问题描述
一场考试的结构如下:
- 考试包含 轮,依次称为第 1 轮到第 轮。
- 在每一轮中,你会得到一个介于 到 (包括两端点)之间的整数分数。
- 你的最终成绩是除最高分和最低分以外,在各轮中获得的 个分数之和。
- 格式上,令 表示按升序排列的各轮所得分数序列,则最终成绩为 。
现在,前 轮考试已经结束,你在第 轮的得分为 。
请打印出在第 轮中你必须至少获得多少分,才能使最终成绩达到或超过 分。
若无论你在第 轮中取得何种分数,最终成绩都无法达到或超过 分,请打印 -1
。
注意:你在第 轮中的分数只能是一个介于 和 之间的整数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is an exam structured as follows.
- The exam consists of rounds called round to .
- In each round, you are given an integer score between and , inclusive.
- Your final grade is the sum of the of the scores earned in the rounds excluding the highest and lowest.
- Formally, let be the sequence of the scores earned in the rounds sorted in ascending order, then the final grade is .
Now, rounds of the exam have ended, and your score in round was .
Print the minimum score you must earn in round for a final grade of or higher.
If your final grade will never be or higher no matter what score you earn in round , print -1
instead.
Note that your score in round can only be an integer between and .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
5 180
40 60 80 50
Sample Output 1
70
Your scores in the first four rounds were , , , and .
If you earn a score of in round , the sequence of the scores sorted in ascending order will be , for a final grade of .
It can be shown that is the minimum score you must earn for a final grade of or higher.
Sample Input 2
3 100
100 100
Sample Output 2
0
Your scores in the first two rounds were and .
If you earn a score of in round , the sequence of the scores sorted in ascending order will be , for a final grade of .
Note that the highest score, , is earned multiple times, and only one of them is excluded. (The same goes for the lowest score.)
It can be shown that is the minimum score you must earn for a final grade of or higher.
Sample Input 3
5 200
0 0 99 99
Sample Output 3
-1
Your scores in the first four rounds were , , , and .
It can be shown that your final grade will never be or higher no matter what score you earn in round .
Sample Input 4
10 480
59 98 88 54 70 24 8 94 46
Sample Output 4
45
update @ 2024/3/10 01:40:13