Feedback | If you notice incorrect translations in Contester, please let author know.
|
|
Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Ibrahim Mesecan.
Group Average
Question:
In a file you have the number of questions solved
by students from different groups. Write a
program that calculates the average of all
groups and sorts them in descending according
to the averages. If there are two groups with
the same average show them in ascending order
according to the group names.
Input specification:
At the beginning, you will be given two integers:
the number of students (n) and the number of top m
groups to list. Then in the following n lines,
you will be given two information: the group
of the student (grp) and the number of questions
solved (k) by this student, where
- grp is a string with at most 10 chars
- k is a positive integer not greater than 10,000
and 1 ≤ m ≤ n ≤ 10,000.
Output specification:
Show top m groups.
Sample Input
6 2
CEN1 20
CEN1 28
CEN2 10
ECE1 21
CEN2 10
ECE1 19
|
Sample Output
CEN1
ECE1
|
Explanation:
The average of
- CEN1 is 24,
- ECE1 is 20, and
- CEN2 is 10.
Thus, the top two groups are CEN1 and ECE1.
Для отправки решений необходимо выполнить вход.
|