Connection Status:
Competition Arena > CSCourse
SRM 131 · 2003-01-30 · by pmadden
Class Name: CSCourse
Return Type: String
Method Name: finalgrade
Arg Types: (vector<int>, int)
Problem Statement

Problem Statement

Professor M wants his class to compete in TopCoder events. Students will be required to compete a minimum of three times during the semester.

Possible grades (in descending order) are "A", "B", "C", "D", or "F". If the student does not compete in at least three events, an "A" will be reduced to a "B", a "B" will be reduced to a "C", a "C" will be reduced to a "D", and a "D" will be reduced to an "F". As "F" is the lowest grade possible, it will not be reduced further.

An initial grade is determined by the total score over 5 assignments; each assignment is worth 20 points, and the student grade for an assignment will be between 0 and 20 (inclusive). Total scores determine an initial grade as follows.

  • 90 to 100 (inclusive): A
  • 80 to 89 (inclusive): B
  • 70 to 79 (inclusive): C
  • 60 to 69 (inclusive): D
  • Below 60: F

Create a class CSCourse which contains a method finalgrade that takes a int[] scores which contains a student's scores on each of the five assignments, and an int events which represents the number of TopCoder events in which that student participated, and returns a String representing that student's final grade.

Constraints

  • scores will contain exactly 5 elements.
  • Each element of scores will be between 0 and 20, inclusive.
  • events will be between 0 and 100, inclusive.
Examples
0)
{20,20,20,20,20}
3
Returns: "A"

This student got a perfect score, and competed in three events.

1)
{20,20,20,20,19}
0
Returns: "B"

This student has an almost perfect score, but is reduced to a B because he did not compete in TopCoder events.

2)
{0,0,0,0,0}
0
Returns: "F"
3)
{20,20,20,20,0}
3
Returns: "B"
4)
{20,20,20,20,0}
0
Returns: "C"

Submissions are judged against all 113 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class CSCourse with a public method string finalgrade(vector<int> scores, int events) · 113 test cases · 2 s / 256 MB per case

Submitting as anonymous