Compute my GPA
Time limit1sMemory limit256 MB
Compute each semester total credits and credit-weighted GPA from course credits and grades, rounded to one decimal place.
- Level
Easy1 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Geunwoo spends all his time playing and suddenly wants to know his grade average. He finds logging in to the academic system too much trouble, so compute the credit total and the GPA of each semester for him.
The credit total of a semester is the sum of the credits of every course taken that semester. The GPA is the sum of times the grade over all courses, divided by the credit total.
Input
The first line contains the number of semesters . is an integer of at least .
The information for the semesters follows. Each semester starts with a line holding the number of courses taken that semester, then lines follow, each holding the credit and the grade of one course, separated by a space. (, , is an integer)
is one of , , , , , , , , , , , , , and its fractional part is given to at most one digit. A grade whose fractional part is can appear as an integer such as or in decimal form such as .
Output
For each semester, print the credit total and the GPA on one line, separated by a space.
Print the credit total as an integer. Print the GPA rounded to one decimal place, rounding up when the second decimal digit is exactly . Always print one digit after the decimal point, so an exact integer GPA prints as or .