HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN112 Questions 2016 > problem:


15-FE-4. 50995 - Group Average

CEN112 Questions 2016

Start: Mar.30.2016 at 03:10:22 PM
Finish: Apr.01.2016 at 05:00:00 AM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 15-FE-1. 50992 - Top K Obese Classes
• 15-FE-2. 50993 - Products in store
• 15-FE-3. 50994 - The Most Crowded...
• 15-FE-4. 50995 - Group Average
• 15-FE-6. 50989 - Rectangles and Points
• 15-FE-7. 50990 - Two Neighbors
• 15-FE-8. 50991 - Intersecting Circles
• 15-HW-2. 50932 - Shifting rows and...
• 15-HW-3. 50933 - Sum of the Bigges...
• 15-HW-4. 50934 - Selling Cars
• 15-HW-5. 50935 - Max Discount
• 15-MdtE-1. 50915 - Trip to Korca

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.



Для отправки решений необходимо выполнить вход.

www.contester.ru