Honk's pool(暴力,巧妙)
明若清溪天下绝歌 缱绻成说,不知该在哪处着墨;一生情深怎奈何世事 徒留斑驳,只一念痴恋成奢。 As we all know, Honk has nn pools, numbered as 11 ~ nn . There is a_iai? liters water in the ii-th pool. Every day, Honk will perform the following operations in sequence.
- Find the pool with the most water (If there are more than one, choose one at random) and take one liter of water.
- Find the pool with the least water (If there are more than one, choose one at random) and pour one liter of water into the pool.
- Go home and rest (Waiting for the next day).
Input The input consists of multiple test cases. The input is terminated by the end of file.The number of data sets will not exceed 40
The first line of each test case contains two integers nn and kk, which indicate the number of pools and the number of days to operate the pool.
The second line of each test case contains nn integers, and the ii-th number represent a_iai? indicating the initial amount of water in the ii-th pool.
1 \le n \le 5000001≤n≤500000, 1 \le k \le 10^91≤k≤109, 1 \le a_i \le 10^91≤ai?≤109.
Output For each test case, print one line containing the answer described above.
样例输入1复制
4 100 1 1 10 10
样例输出1复制
1
样例输入2复制
4 3 2 2 2 2
样例输出2复制
0
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include