GPA ranking
题号:NC24646
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
64bit IO Format: %lld

题目描述

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 GPA
separated 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.

 

示例1

输入

复制
2
2 2
4 2
1001 91 85 82 75 80 90
1002 76 82 89 95 90 90
3 1
2
1002 90 70 85
1001 85 70 90
1003 90 95 96

输出

复制
1001 84.77
1002 84.43
------
1003 92.70
1002 83.00
1001 81.50