It is well known that GPA is a comprehensive way to evaluate a student’s ability. We consider the method of calculating GPA is the sum of the grade of each course multiplied by the corresponding credit of each course, then divided by total credits. And the grade of each course is based on three aspects : test score, performance, and attendance which account for 50%, 30%, 20% respectively. Now we want to calculating GPA of every student and print in one order. As an excellent student, can you solve the problem.
Ps: ∑(grade*credit)/∑(credit)
The first line of the input contains a positive integer T indicating the number of test cases. T test cases follow. Each test case starts with two integers N and M which indicate the number of students and the number of courses. The second line contains M positive integers which mean the credit of each course (in the range of [1, 6]). Then N lines follow, each contains a studentID which is string of 4 digits, followed by the 3*M integers (in the range of [0, 100]), which from left to right every three integers indicate test score, performance and attendance of one course respectively.
Ps: all students take the same courses.
T(1<=T<=10)
N(1<=N<=60)
M(1<=M<=10)
Each test case is separated by “------” . For each test case, print N lines and each line with the format: studentID GPAseparated by one space and no extra spaces behind each line and GPA accurate up to 2 decimal places. The output must be sorted in descending order of student’s GPA.If there is a tie, output in ascending order of studentID. It’s guaranteed that the studentID is distinct.