TopCoder problem "AimToTen" used in SRM 273 (Division II Level One)



Problem Statement

    You are given a int[] marks containing the grades you have received so far in a class. Each grade is between 0 and 10, inclusive. Assuming that you will receive a 10 on all future assignments, determine the minimum number of future assignments that are needed for you to receive a final grade of 10. You will receive a final grade of 10 if your average grade is 9.5 or higher.
 

Definition

    
Class:AimToTen
Method:need
Parameters:int[]
Returns:int
Method signature:int need(int[] marks)
(be sure your method is public)
    
 

Constraints

-marks has between 1 and 50 elements, inclusive.
-Each element of marks is between 0 and 10, inclusive.
 

Examples

0)
    
{9, 10, 10, 9}
Returns: 0
Your average is already 9.5, so no future assignments are needed.
1)
    
{8, 9}
Returns: 4
In this case you need 4 more assignments. With each completed assignment, your average could increase to 9, 9.25, 9.4 and 9.5, respectively.
2)
    
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Returns: 950
3)
    
{10, 10, 10, 10}
Returns: 0

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=5879

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=8070&pm=5879

Writer:

supernova

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

Simple Search, Iteration