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

这个题就是让你算要加几个K,使得总数的平均值四舍五入等于k。

代码:

#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int main(){
int a[];
int n,m;
double sum,ave;
while(~scanf("%d",&n)){
scanf("%d",&m);
sum=;
for(int i=;i<n;i++){
scanf("%d",&a[i]);
sum+=a[i]*1.0;
}
ave=sum/n;
if(ave>=(m*1.0-0.5)) printf("0\n");
else{
for(int i=;i<=N;i++){ //这里的N要大一些,我一开始写的i<=n*m,太小了,会wa
sum+=m*1.0;
ave=sum/(n+i);
if(ave>=(m*1.0-0.5)){
printf("%d\n",i);
break;
}
}
}
}
return ;
}

Codeforces Round #415(Div. 2)-810A.。。。 810B.。。。 810C.。。。不会的更多相关文章

  1. Codeforces Round #415 (Div. 2)(A,暴力,B,贪心,排序)

    A. Straight «A» time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...

  2. Codeforces Round#415 Div.2

    A. Straight «A» 题面 Noora is a student of one famous high school. It's her final year in school - she ...

  3. Codeforces Round #415 Div. 1

    A:考虑每对最大值最小值的贡献即可. #include<iostream> #include<cstdio> #include<cmath> #include< ...

  4. Codeforces Round #415 (Div. 2)C

    反正又是一个半小时没做出来... 先排序,然后求和,第i个和第j个,f(a)=a[j]-a[i]=a[i]*(2^(j-i-1))因为从j到i之间有j-i-1个数(存在或者不存在有两种情况) 又有a[ ...

  5. Codeforces Round #415 (Div. 2) A B C 暴力 sort 规律

    A. Straight «A» time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  6. Codeforces Round #415 (Div. 2) C. Do you want a date?

    C. Do you want a date?   2 seconds 256 megabytes   Leha decided to move to a quiet town Vičkopolis, ...

  7. Codeforces Round #415 (Div. 2) B. Summer sell-off

    B. Summer sell-off time limit per test   1 second memory limit per test   256 megabytes   Summer hol ...

  8. Codeforces Round #415 (Div. 2) 翻车啦

    A. Straight «A» time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  9. Codeforces Round #415 (Div. 1) (CDE)

    1. CF 809C Find a car 大意: 给定一个$1e9\times 1e9$的矩阵$a$, $a_{i,j}$为它正上方和正左方未出现过的最小数, 每个询问求一个矩形内的和. 可以发现$ ...

随机推荐

  1. iOS学习——内存泄漏检查及原因分析

    项目的代码很多,前两天老大突然跟我说项目中某一个ViewController的dealloc()方法没有被调用,存在内存泄漏问题,需要排查原因,解决内存泄漏问题.由于刚加入项目组不久,对出问题的模块的 ...

  2. iOS 图片的拉伸,取固定区域显示

    1.图片拉伸合适的尺寸 以及清晰度 UIButton * but =[[UIButton alloc]initWithFrame:CGRectMake(, , , )]; //拉伸 /*UIImage ...

  3. http中的get和post(一)

    GET和POST有什么区别?及为什么网上的多数答案都是错的. 如果有人问你,GET和POST,有什么区别?你会如何回答? 我的经历 前几天有人问我这个问题.我说GET是用于获取数据的,POST,一般用 ...

  4. Java用代码获取classes目录下的文件的方式

    假设我们有个Maven的Web项目,其中有src/main/java和src/main/resources两个输出目录(注意这两个目录下的内容运行后都会输出到classes目录下), 而在src/ma ...

  5. ArcGIS 网络分析[8.3] 设置IDENetworkDataset的属性及INetworkDataset的对比/创建网络数据集

    创建网络数据集就得有各种数据和参数,这篇文章很长,慎入. 网络分析依赖于网络数据集的质量,这句话就在这里得到了验证:复杂.精确定义. 本节目录如下: 1. INetworkDataset与IDENet ...

  6. OpenStack运维(四):OpenStack备份恢复

    1.备份注意事项 要保留多少备份? 是否需要异地备份? 备份间隔多久? 恢复策略? 2.备份什么 2.1 数据库备份 2.1.1  制定crond 每天备份一次 2.1.2 备份命令根据系统而定,可用 ...

  7. Python学习(一):编写购物车

    1.购物车流程图: 2.代码实现: #!/usr/bin/env python #coding=utf-8 ChoiceOne =''' 1.查看余额 2.购物 3.退出 ''' ChoiceTwo ...

  8. mintUI配合vue2.0,webpack,vue-cli脚手架从零搭建

    步骤说明: 1.确保安装了vue-cli 安装:cnpm install vue-cli -g 验证版本:vue --version 2.生成项目模板: vue init webpack-simple ...

  9. MySQL:表的操作 知识点难点总结:表完整性约束及其他常用知识点二次总结🙄

    表操作 一 : 修改表表表表表表表表表: ALTER TABLE 语法 1. 改表名rename alter table 表名 rename 新表名 2. 增加字段add alter table 表名 ...

  10. ASP.NET MVC框架开发系列教程

    本系列教程是自己在工作中使用到而记录的,如有错误之处,请给与指正 文章目录 MVC4 开篇 第一章 初识MVC4 第二章 下山遇虎(@helper) 第三章 Models模块属性详解 第四章 在MVC ...