AimToTen
SRM 273 · 2005-11-21 · by supernova
SRM 273 · 2005-11-21 · by supernova · Simple Search, Iteration
Problem Statement
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.
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)
{9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
9, 9, 9, 9, 9, 10, 10, 10, 10, 10}
Returns: 0
4)
{1, 5, 1, 8, 10, 10, 1}
Returns: 61
Submissions are judged against all 76 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class AimToTen with a public method int need(vector<int> marks) · 76 test cases · 2 s / 256 MB per case