Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. Karl-Gunnar vying for the presidency of his sports club and do not want to risk losing the vote. He has managed to find out which candidate each member will vote on and think simply bribe a number of members so that they vote for him instead. Write a program that calculates how many votes that must be purchased (ie members who need to be bribed) to Karl-Gunnar should win the vote. To win requires that you get more votes than each of the other candidates.
  2.  
  3. Input
  4. In the first line is an integer: the number of candidates (1 ≤ n ≤ 20). The second row is n integer (between 0 and 1000): the number of votes each candidate would receive no bribes. The first number indicates the Karl-Gunnar's voices.
  5.  
  6. Output
  7. The program should print a line with an integer: the minimum number of votes that need to be purchased to Karl-Gunnar will get more votes than each of the other candidates.
  8.  
  9. Example: Input
  10. 4
  11. 2:05 a.m. 7:08 a.m.
  12. Example: Output
  13. 5
  14. Example: Explanation
  15. Karl-Gunnar, for example, buy 3 votes that would have fallen to the fourth candidate and two votes that would have fallen to the third candidate. Then he himself seven votes, while other candidates get 5 votes.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement