Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Ibrahim Mesecan.
CEN112 Homework, quiz average
In CEN112, students are offered 5 homework
practice exam or quiz in total. But, for
the convenience of students, they are
required to complete only 4 of them. They may
skip any of the Homework or quiz. Or, if they
complete all five, the average is calculated out
of the best four grades.
Note: The average is 0, if the student
takes no quiz or homework.
Question: Write a program
which reads the grades of n students. Then, the
program will show order of the top m students
according to the averages. If there are two students
with the same average, show first the one whose
order is smaller.
Input specification:
In the first line, you will be given two integers:
the number of students (n), and the number of top (m)
students to list.
The following n lines contain at most 5 integers
ending with a negative number where the grades are between
1 and 100 and 1 ≤ m ≤ n ≤ 10,000.
Output specification:
Show m integers (orders of students).
Sample Input
6 3
43 67 61 -1
76 40 76 74 94 -1
74 88 87 92 43 -1
48 88 46 77 -1
41 88 46 81 46 -1
100 100 -1
|
Sample Output
3 2 5
|
Explanation:
The grades of 6 students are given. Here is the table of averages.
Student # |
Nr. of Grades |
Sum of Grades |
Student Ave |
1 | 3 |
171 | 42.75 |
2 | 5 |
360 | 80 |
3 | 5 |
384 | 85.25 |
4 | 4 |
259 | 64.75 |
5 | 5 |
302 | 65.25 |
6 | 2 |
200 | 50 |
So, the third student has the highest average.
Then, the second student comes, etc.
Для отправки решений необходимо выполнить вход.
|