302943: CF574A. Bear and Elections

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Bear and Elections

题意翻译

### 题目描述 `Limak`前来参加选举。 在选举中,候选人总共有$n$位,第$i$位候选人当前的选票是$a_{i}$。 `Limak`十分渴望权力,于是他决定使用下作的手段赢得选举——贿赂市民。对于每一个市民,`Limak`只需要一颗糖果就可以贿赂他。 请问,`Limak`至少需要几颗糖果才能赢得选举? ### 输入输出格式 #### 输入格式: 第一行,一个整数$n$; 第二行,$n$个正整数,表示第$i$位候选人当前的选票$a_{i}$; #### 输入格式: 输出`Limak`至少需要几颗糖果才能赢得选举; ### 说明 $2 \leq n \leq 100$; $1 \leq a_{i} \leq 1000$;

题目描述

Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland. There are $ n $ candidates, including Limak. We know how many citizens are going to vote for each candidate. Now $ i $ -th candidate would get $ a_{i} $ votes. Limak is candidate number $ 1 $ . To win in elections, he must get strictly more votes than any other candidate. Victory is more important than everything else so Limak decided to cheat. He will steal votes from his opponents by bribing some citizens. To bribe a citizen, Limak must give him or her one candy - citizens are bears and bears like candies. Limak doesn't have many candies and wonders - how many citizens does he have to bribe?

输入输出格式

输入格式


The first line contains single integer $ n $ ( $ 2<=n<=100 $ ) - number of candidates. The second line contains $ n $ space-separated integers $ a_{1},a_{2},...,a_{n} $ ( $ 1<=a_{i}<=1000 $ ) - number of votes for each candidate. Limak is candidate number $ 1 $ . Note that after bribing number of votes for some candidate might be zero or might be greater than $ 1000 $ .

输出格式


Print the minimum number of citizens Limak must bribe to have strictly more votes than any other candidate.

输入输出样例

输入样例 #1

5
5 1 11 2 8

输出样例 #1

4

输入样例 #2

4
1 8 8 8

输出样例 #2

6

输入样例 #3

2
7 6

输出样例 #3

0

说明

In the first sample Limak has $ 5 $ votes. One of the ways to achieve victory is to bribe $ 4 $ citizens who want to vote for the third candidate. Then numbers of votes would be $ 9,1,7,2,8 $ (Limak would have $ 9 $ votes). Alternatively, Limak could steal only $ 3 $ votes from the third candidate and $ 1 $ vote from the second candidate to get situation $ 9,0,8,2,8 $ . In the second sample Limak will steal $ 2 $ votes from each candidate. Situation will be $ 7,6,6,6 $ . In the third sample Limak is a winner without bribing any citizen.

Input

题意翻译

### 题目描述 `Limak`前来参加选举。 在选举中,候选人总共有$n$位,第$i$位候选人当前的选票是$a_{i}$。 `Limak`十分渴望权力,于是他决定使用下作的手段赢得选举——贿赂市民。对于每一个市民,`Limak`只需要一颗糖果就可以贿赂他。 请问,`Limak`至少需要几颗糖果才能赢得选举? ### 输入输出格式 #### 输入格式: 第一行,一个整数$n$; 第二行,$n$个正整数,表示第$i$位候选人当前的选票$a_{i}$; #### 输入格式: 输出`Limak`至少需要几颗糖果才能赢得选举; ### 说明 $2 \leq n \leq 100$; $1 \leq a_{i} \leq 1000$;

加入题单

上一题 下一题 算法标签: