HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50847 - The first m trains to leave

Guest
• Review clarifications (1)

Volume problems

• 50434 - Row Min Subtraction
• 50870 - ZScore normalization
• 50869 - Birthday Celebration
• 50821 - Derivative of an array
• 50513 - Climbing Up the Stairs
• 50854 - Area of Triangle Revised
• 50520 - Filling a Matrix Randomly
• 50497 - Falling Bricks - Revisited
• 50847 - The first m trains to leave
• 50669 - Area of an Irregular Polygon
• 50860 - Number of Student Certificates
• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 51011 - Decoding the Path
• 51019 - Finding the hidden message
• 51002 - The most successful classes
• 50525 - Ordering Pizza

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.

The first m trains to leave

You have started working in Tirana central train station. The chief wants a program for adjusting railroad switches. In order to avoid accidents, they need to adjust railroad switches properly. You have the arrival and stay times for the trains.

Question: Write a program that is going to get information for n trains and it will show m trains which leave the earliest.

Input specification
In the first line, you will be given two integers: The number of trains(n) and the number of trains to show (m), where 0 ≤ m ≤ n ≤ 40,000. Then, in the following n lines, you will be given 4 integers

  • arrival time of the train (h, m, s)
  • The time in minutes (k) that the train stays in the station .
where 0 ≤ h ≤ 23, 0 ≤ m and s ≤ 59, and 0 ≤ k ≤ 10,000.
Note: Pay attention that a train might leave some days after.

Output specification:
Show ids of m trains which leave the earliest. If there are two trains to leave at the same time, show the train with smaller id first.

Sample Input I
3 2
14 30 26 85
14 20 06 115
14 35 24 65
Sample Output I
3 1

Explanation:

  1. The first train stays 85 minutes and leaves at: 15:55:26
  2. The second train leaves at: 16:15:06
  3. The third train leaves at: 15:40:24
Then the sorted list of trains will 3, 1 and 2.



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

www.contester.ru