| Felix Halim .NET | ||
|
University Experience
IOI 2002 Yong In, Korea
ACM ICPC Regional Manila 2003
ACM ICPC Regional Manila 2004
ACM ICPC Regional Manila 2005
ACM ICPC Regional Kaohsiung 2006
ACM ICPC Regional Singapore 2007
ACM ICPC World Final Tokyo 2007
Google India Code Jam 2005
Google India Code Jam 2006
Indonesia National Contest 2007
Indonesia National Contest 2008
|
||
Problem StatementAn election has just occurred. Given a int[] votes, where votes[i] is the number of votes for the ith candidate, you want to find the percentage of the total number of votes received by each candidate. If the percentage is not an integer, it must be rounded to an integer; you can choose to round up or down. You must make your choices in such a way that the sum of the percentages is exactly 100. Return the number of percentages for which you round up. DefinitionClass: GeneralElection Method: numberOfRoundedUp Parameters: int[] Returns: int Method signature: int numberOfRoundedUp(int[] votes) (be sure your method is public) Constraints
Examples
0)
{253, 253, 253, 241}
Returns: 1
The percentages are {25.3, 25.3, 25.3, 24.1}. If we round all the percentages down, the sum will be equal to 25 + 25 + 25 + 24 = 99. Therefore, one of the percentages must be rounded up.
1)
{2, 3}
Returns: 0
The raw percentages are 40.0 and 60.0. They are already integers.
2)
{500, 500}
Returns: 0
The raw percentages are 50.0 and 50.0. They are already integers.
3)
{1,2,3,4,5}
Returns: 2
4)
{1000}
Returns: 0
5)
{2,3,5,7,11,13,2,4,8,16}
Returns: 5
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. Google India Code Jam 2006 - Table of Contents
|
||