CF810A.Straight «A»

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Noora is a student of one famous high school. It's her final year in school — she is going to study in university next year. However, she has to get an «A» graduation certificate in order to apply to a prestigious one.

In school, where Noora is studying, teachers are putting down marks to the online class register, which are integers from 1 to k. The worst mark is 1, the best is k. Mark that is going to the certificate, is calculated as an average of all the marks, rounded to the closest integer. If several answers are possible, rounding up is produced. For example, 7.3 is rounded to 7, but 7.5 and 7.8784 — to 8.

For instance, if Noora has marks [8, 9], then the mark to the certificate is 9, because the average is equal to 8.5 and rounded to 9, but if the marks are [8, 8, 9], Noora will have graduation certificate with 8.

To graduate with «A» certificate, Noora has to have mark k.

Noora got n marks in register this year. However, she is afraid that her marks are not enough to get final mark k. Noora decided to ask for help in the internet, where hacker Leha immediately responded to her request. He is ready to hack class register for Noora and to add Noora any number of additional marks from 1 to k. At the same time, Leha want his hack be unseen to everyone, so he decided to add as less as possible additional marks. Please help Leha to calculate the minimal number of marks he has to add, so that final Noora's mark will become equal to k.

努拉是一所著名高中的学生。今年是她在高中的最后一年——明年她将进入大学学习。然而,为了申请一所声誉卓著的大学,她必须获得一份“A”等级的毕业证书。

在努拉就读的学校中,教师将分数录入在线课堂登记系统,这些分数为 11 到 kk 之间的整数。最低分为 11,最高分为 kk。计入毕业证书的成绩,是所有分数的算术平均值四舍五入到最接近的整数;若该平均值恰好位于两个相邻整数的正中间(即小数部分为 0.50.5),则向上取整。例如:7.37.3 四舍五入为 77,而 7.57.5 和 7.87847.8784 均四舍五入为 88。

举例来说,若努拉的成绩为 [8, 9][8,\,9],则其毕业证书上的成绩为 99,因为平均值为 8.58.5,向上取整得 99;但若成绩为 [8, 8, 9][8,\,8,\,9],则努拉的毕业证书成绩为 88。

要以“A”等级毕业,努拉的最终成绩必须恰好为 kk。

今年努拉已在登记系统中获得了 nn 个成绩。然而,她担心目前的成绩尚不足以使最终成绩达到 kk。努拉决定在网上求助,黑客莱哈立即响应了她的请求。他愿意为努拉黑入课堂登记系统,并为她添加任意多个介于 11 到 kk 之间的额外成绩。同时,莱哈希望自己的入侵行为不被任何人察觉,因此他决定添加尽可能少的额外成绩。请帮助莱哈计算:为使努拉的最终成绩恰好变为 kk,他至少需要添加多少个成绩?

输入格式

The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100) denoting the number of marks, received by Noora and the value of highest possible mark.

The second line contains n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ k) denoting marks received by Noora before Leha's hack.

第一行包含两个整数 nn 和 kk(1 ≤ n ≤ 1001 \leq n \leq 100,1 ≤ k ≤ 1001 \leq k \leq 100),分别表示诺拉获得的成绩数量以及可能的最高分值。

第二行包含 nn 个整数 a1, a2, ..., ana_1, a_2, ..., a_n(1 ≤ ai ≤ k1 \leq a_i \leq k),表示莱哈实施黑客攻击前诺拉所获得的成绩。

输出格式

Print a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to k.

输出一个整数——Leha 需要添加的最少额外分数数量,以使 Noora 的最终成绩变为 kk。

输入输出样例

  • 输入#1

    2 10
    8 9

    输出#1

    4
  • 输入#2

    3 5
    4 4 4

    输出#2

    3

说明/提示

Consider the first example testcase.

Maximal mark is 10, Noora received two marks — 8 and 9, so current final mark is 9. To fix it, Leha can add marks [10, 10, 10, 10] (4 marks in total) to the registry, achieving Noora having average mark equal to . Consequently, new final mark is 10. Less number of marks won't fix the situation.

In the second example Leha can add [5, 5, 5] to the registry, so that making average mark equal to 4.5, which is enough to have 5 in the certificate.

考虑第一个样例测试用例。

最高分为 10 分,Noora 已获得两个分数 —— 8 和 9,因此当前最终成绩为 9。为修正该成绩,Leha 可在登记册中添加分数 [10, 10, 10, 10](共 4 个分数),使得 Noora 的平均分达到 。因此,新的最终成绩为 10。更少数量的分数无法解决该问题。

在第二个样例中,Leha 可在登记册中添加 [5, 5, 5],使得平均分为 4.5,这已足以在证书上获得 5 分。

输入解题思路,AI测评打分。不知道怎么写?

首页