ACM International Collegiate Programming Contest
Japan Domestic, 2003-10-03
The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meeting. So, in order to settle the meeting date, the chairperson requested every member to send back a list of convenient dates by E-mail. Your mission is to help the chairperson, who is now dedicated to other issues of the contest, by writing a program that chooses the best date from the submitted lists. Your program should find the date convenient for the most members. If there is more than one such day, the earliest is the best.
ICPC委員会を早急に開いて次のコンテストの細目すべてを決める必要があった。 しかし,委員は皆,お宅的に(役にも立たない)プログラム開発に忙しく, 委員会の日取りがなかなか決められない。 そこで,委員長は,日取りを決めるべく,全委員に都合のつく日の一覧を Eメールで送るように指示した。君の役目は, コンテストの諸業務に追われる委員長に代わって, 寄せられた一覧から最善の開催日を決めることにある。 プログラムを作って,できる限り多くの委員が参加できる日を選び出すの である。そうした日が複数あるなら,一番早い日を選んで欲しい。
The input has multiple data sets, each starting with a line containing the number of committee members and the quorum of the meeting.
入力には,データの組が複数並ぶ。それぞれのデータの組の最初の行は, 委員会の,委員総数と定足数とが書いてある。
N lines follow, each describing convenient dates for a committee member in the following format.
続いて N 個の行が来る。各行には,それぞれの委員の都合のつく日が つぎの形に並んでいる。
A line containing two zeros indicates the end of the input.
ゼロ2個が並んだ行は,入力の終わりを意味する。
For each data set, print a single line containing the date number convenient for the largest number of committee members. If there is more than one such date, print the earliest. However, if no dates are convenient for more than or equal to the quorum number of members, print 0 instead.
それぞれのデータの組に対して, 委員の最多数にとって都合のよい日の日付番号を書いた1行を出力する。 そうした日が複数あるときは,その最も早いものを書く。 ただし,定足数以上の委員の都合がつく日がない場合は,0 と書く。
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
Test your program against this first input data.
作成したプログラムに この1番目のデータ を処理させてください。
The ACM ICPC