Codeforces Round #415 (Div. 2)A. Straight «A» (暴力)

来源:互联网 发布:移植术后软件 编辑:程序博客网 时间:2024/05/29 19:04
A. Straight «A»
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 from1 to k. The worst mark is1, 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 — to8.

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

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 markk. 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 from1 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.

Input

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 integersa1, a2, ..., an(1 ≤ ai ≤ k) denoting marks received by Noora before Leha's hack.

Output

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

Examples
Input
2 108 9
Output
4
Input
3 54 4 4
Output
3
Note

Consider the first example testcase.

Maximal mark is 10, Noora received two marks —8 and 9, so current final mark is9. 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 is10. 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.


题意:其实就是让求需要加上多少个k才能使平均分大于等于 (k-0.5)


分析:直接暴力就可以了


AC代码:

#include<stdio.h>#include<string.h>double a[200];int main(){int n;double aim;scanf("%d%lf",&n,&aim);double ave=0;for(int i=0;i<n;i++){scanf("%lf",&a[i]);ave+=a[i];}int t=0;double ans=ave/(n*1.0);while(ans<aim-0.5){t++;ans=(ave+t*aim)/double(n+t);}printf("%d\n",t);} 


阅读全文
0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 老年人脚肿并痛怎么办 孩子蛙跳肌后大腿痛怎么办 走路久了腿酸怎么办 走路多了膝盖痛怎么办 走路多了小腿痛怎么办 走多了腿疼怎么办 小腿走多了酸痛怎么办 腿肚受凉了酸痛怎么办 晚上腿疼的睡不着觉怎么办 走路走多了腿酸怎么办 跳完蛙跳大腿疼怎么办 走路走多了脚疼怎么办 走太多路脚酸痛怎么办 走路走的腿酸痛怎么办 路走得太多腿疼怎么办 走路走的足弓疼怎么办 走路走多了膝盖怎么办 2岁宝宝走路一只脚内八字怎么办 6岁宝宝o型腿怎么办 一岁宝宝o型腿怎么办 宝宝一岁o型腿怎么办 宝宝一周两个月走路弓着腿怎么办 宝宝腿走路膝盖弯曲怎么办 两岁宝宝不爱走路怎么办 水鸭子脚不能走了怎么办 鸭子坐着脚走不动怎么办 鸭子步走了腿疼怎么办? 跳爵士舞没感觉怎么办 军校学员体能考核不达标怎么办 俯卧撑新兵连做不动怎么办 宝宝胆小不敢上体能课怎么办 28岁老太太抬头纹剩两颗怎么办 大腿前侧抽筋痛怎么办 电脑看片缓冲慢怎么办 跑步跑的腿疼怎么办 第一次去健身房练瑜伽不会怎么办 跑步过后腿筋疼怎么办 俯卧撑只能做20个怎么办 被裤裆峰咬了怎么办? 新兵5公里不想跑怎么办 老公掉粪坑了你怎么办