CF166C.Median

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

A median in an array with the length of nn is an element which occupies position number after we sort the elements in the non-decreasing order (the array elements are numbered starting with 11 ). A median of an array (2,6,1,2,3)(2,6,1,2,3) is the number 22 , and a median of array (0,96,17,23)(0,96,17,23) — the number 1717 .

We define an expression as the integer part of dividing number aa by number bb .

One day Vasya showed Petya an array consisting of nn integers and suggested finding the array's median. Petya didn't even look at the array and said that it equals xx . Petya is a very honest boy, so he decided to add several numbers to the given array so that the median of the resulting array would be equal to xx .

Petya can add any integers from 11 to 10510^{5} to the array, including the same numbers. Of course, he can add nothing to the array. If a number is added multiple times, then we should consider it the number of times it occurs. It is not allowed to delete of change initial numbers of the array.

While Petya is busy distracting Vasya, your task is to find the minimum number of elements he will need.

输入格式

The first input line contains two space-separated integers nn and xx ( 1<=n<=5001<=n<=500 , 1<=x<=1051<=x<=10^{5} ) — the initial array's length and the required median's value. The second line contains nn space-separated numbers — the initial array. The elements of the array are integers from 11 to 10510^{5} . The array elements are not necessarily different.

输出格式

Print the only integer — the minimum number of elements Petya needs to add to the array so that its median equals xx .

输入输出样例

  • 输入#1

    3 10
    10 20 30
    

    输出#1

    1
    
  • 输入#2

    3 4
    1 2 3
    

    输出#2

    4
    

说明/提示

In the first sample we can add number 99 to array (10,20,30)(10,20,30) . The resulting array (9,10,20,30)(9,10,20,30) will have a median in position , that is, 1010 .

In the second sample you should add numbers 44 , 55 , 55 , 55 . The resulting array has median equal to 44 .

首页