Codeforces Round #415 A Straight <<A>>
来源:互联网 发布:触发器sqlserver 编辑:程序博客网 时间:2024/06/03 16:08
time limit per test1 second
memory limit per test256 megabytes
Description
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.
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 integers a1, 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 to k.
Examples
Input
2 10
8 9
Output
4
Input
3 5
4 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 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.
这题很水呀,简单一个while循环就解决啦 (=゚ω゚)ノ
#include<bits/stdc++.h>using namespace std;double n,k;int main(){ double sum=0; double mark; scanf("%lf%lf",&n,&k); for(int i=0;i<n;i++) { scanf("%lf",&mark); sum+=mark; } //cout<<sum; int cnt=0; //printf("%lf\n",sum/n); while((sum/n)<k-0.5) { cnt++; n++; sum+=k; //printf("%d\n",cnt); } printf("%d\n",cnt);}
- Codeforces Round #415 A Straight <<A>>
- Codeforces Round #415 (Div. 2) A. Straight «A»
- Codeforces Round #415 (Div. 2) A. Straight «A»
- Codeforces Round #415 (Div. 2)A. Straight «A» (暴力)
- CodeForces 810A Straight <<A>> 【数学】【模拟】
- 【Codeforces 808 A. Straight «A»】
- codeforces 810A Straight <<A>> 暴力
- codeforces 810A Straight «A»
- Codeforces 810A Straight «A» 题解
- codeforces round#283 A
- Codeforces Round #234A
- Codeforces Round #439 A
- A. Straight «A»
- codeforces div2 round#231 A
- codeforces div2 round#230 A
- Codeforces Round #2A Winner
- Codeforces Round #4A. Watermelon
- Codeforces Round #270 A~D
- 常用DOS命令
- Activity进出动画全局统一配置
- (45)项目设置
- 左倾堆和斜堆
- 观察者模式
- Codeforces Round #415 A Straight <<A>>
- Week Training: 486 Predict the Winner
- mysql 5.7.14 文件夹安装服务向导
- 第一周(2)——项目范围界定
- MySQL 基础——使用通配符进行搜索过滤
- 添加当前用户到sudoers里面
- 『ORACLE』查看所有视图(11g)
- 基于ARM Cortex -A8 的S5PV210处理器的学习笔记(1)
- 前端过滤文本中的关键字