CF1037B Reach Median

题目描述

**题目大意:** 给定一个长度为$n$的序列和一个整数$s$,$n$一定为奇数 一次操作可以将序列中的某个数$+1$或者$-1$,问至少几次操作可以使这个序列的中位数等于$s$

输入格式

第一行,两个整数$n,s$ 第二行,$n$个整数,表示序列中的数

输出格式

一个整数,表示最少的操作次数

说明/提示

In the first sample, $ 6 $ can be increased twice. The array will transform to $ 8, 5, 8 $ , which becomes $ 5, 8, 8 $ after sorting, hence the median is equal to $ 8 $ . In the second sample, $ 19 $ can be increased once and $ 15 $ can be increased five times. The array will become equal to $ 21, 20, 12, 11, 20, 20, 12 $ . If we sort this array we get $ 11, 12, 12, 20, 20, 20, 21 $ , this way the median is $ 20 $ .