HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Sorting and sequences > problem:


50998 - CEN112 Homework, quiz average

Guest
• Review clarifications (1)

Section problems

• 50754 - Team Standings
• 50358 - Series of Odd Numbers
• 50756 - Average of the Nth Student
• 50757 - National Elections - 1
• 50755- Top N Donors - 1
• 50752 - Student Groups
• 50753 - Average of the Nth Student
• 50751 - The biggest Minute
• 50998 - CEN112 Homework, quiz...
• 50804 - Marathon
• 50835 - Club Presidency
• 50747 - Safe boxes against thieves
• 50742 - King Arthur II
• 50352 - Selling Cows
• 50872 - Top M Grades
• 50868 - Sort Frequencies
• 50912 - Trip to Librazhd

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.

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
13 17142.75
25 36080
35 38485.25
44 25964.75
55 30265.25
62 20050
So, the third student has the highest average. Then, the second student comes, etc.



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

www.contester.ru