Minimum Grade
InterviewTime limit1sMemory limit1024 MB
Given the grades of N-1 courses and a target GPA, find the lowest grade for the last course that makes the truncated semester average exceed the target.
- Level
Easy2 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Statement
You are given the minimum average grade point (GPA) you must reach this semester and the grades of every course you took this semester except one. Print the lowest grade you must earn in the remaining course to meet the minimum. The grade-to-point conversion table is below.
The semester average is the sum of (credits points) over all courses, divided by the total credits this semester, then truncated after the second decimal place. The minimum is met only if the semester average is greater than the minimum. Floating-point types can introduce rounding errors, so take care with them.
Input
The first line contains the number of courses taken this semester and the minimum average grade point , separated by a space. (, , and is a real number given to two decimal places.)
From the second line through the next lines, each line gives the credits and the grade of one course, separated by a space. (, and is one of A+, A0, B+, B0, C+, C0, D+, D0, F.)
The next line contains the credits of the remaining course. ()
Output
Print the lowest grade you must earn in the remaining course to meet the minimum average grade point. If no grade can meet the minimum, print impossible.