A11051 | Straight «A»
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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$ .
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$ .
输入格式
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.
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.
输出格式
Print a single integer — minimal number of additional marks, that Leha has to add in order to change Noora's final mark to $k$ .
输入输出样例
输入 #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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted