Education
SRM 196 · 2004-05-27 · by dgoodman
Problem Statement
We will assume that an average score of 90 or higher is rewarded with an A grade, 80 or higher (but less than 90) is a B, 70 or higher (but less than 80) is a C, 60 or higher (but less than 70) is a D. All test scores are integers between 0 and 100 inclusive and the average is NOT rounded -- for example an average of 89.99 does NOT get you an A.
Create a class Education that contains a method minimize that is given a
The desired grade will be given as a
Constraints
- desire will be "A", "B", "C", or "D"
- tests will contain between 0 and 20 elements inclusive.
- Each element of tests will be between 0 and 100 inclusive.
"A"
{0,70}
Returns: -1
Even a perfect 100 on the last test will only produce an average score of 56.66 so it is not possible to earn an A.
"D"
{100,100,100,100,100,100}
Returns: 0
Nice scores! Even the worst possible score of 0 will give an average of 85.7 earning a B which satisfies your meager desire.
"B"
{80,80,80,73}
Returns: 87
An 87 added to these scores will just exactly improve your average from 78.25 to 80.
"B"
{80,80,80,73,79}
Returns: 88
"A"
{80}
Returns: 100
Submissions are judged against all 23 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Education with a public method int minimize(string desire, vector<int> tests) · 23 test cases · 2 s / 256 MB per case