HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50983 - Course Selection

Guest
• Review clarifications (2)

Volume problems

• 50746 - Most Visited
• 50749 - Min Distance
• 50915 - Trip to Korca
• 50985 - Books Waiting
• 50927 - Health Expenses
• 50745 - Bitonic Sequence
• 51083 - Grades Histogram
• 50789 - Number of Cities
• 50983 - Course Selection
• 51024 - Total Stock Price
• 50987 - Very Looong Queue
• 50913 - Manhattan Distance
• 51008 - Sum of Regional Maxes
• 50729 - Max number in 2D array
• 50981 - Top popular m-students
• 51014 - Nine Men's Morris game
• 50743 - Total Scholarships Discount

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.

Course Selection

Question: At the university, there are many courses for students. The courses have quotas and the students are able to choose courses if there is a sit in the course. Write a program that reads course selection list of n students, and then, list top m courses according to the number of students chosen.

Input specification
You will be given three integers in the beginning:

  • The number of students (n): an integer not greater than 20,000.
  • The quota for the courses (m): not more than m students can join to the courses
  • The number of courses to list (k): list top k courses.
Then, the following n lines starts with an integer, (k) the number of preferences of this student. Then, you will be given k course codes which are at most 8 char long alphanumeric text. The order of students defines the course selection. The first student has the highest priority for course selection. etc. Next student can join to a course, if not m students before him have selected the respected course.

Output specification:
Show the top k courses in descending order according to the number of students selected. If the two courses were selected with the same number of students, first show the course which is alphabetically smaller.

Sample Input
5 3 2
2 CEN103 CEN112
2 CEN111 CEN112
3 CEN103 CEN111 CEN211
2 CEN111 CEN211
3 CEN103 CEN111 CEN112
Sample Output
CEN103
CEN111

Explanation: There are 5 students. All the courses have the quota of 3 (each course can be chosen by at most 3 students). Then, list top 2 courses.

Course Code Number of students applied
CEN103 3
CEN111 4
CEN112 3
CEN211 2
But, because the max quota is 3, CEN111 can be selected by at most 3 students. Then, top two courses according to the alphabetic order CEN103, CEN111.



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

www.contester.ru