#K36497. Package Update Tracker
Package Update Tracker
Package Update Tracker
You are given a list of package status updates. Each update consists of three pieces of information: the package ID, the checkpoint time in the format \(HH:MM\), and the status message. Your task is to determine the latest status for each package. The latest status is determined based on the time: for each package, the update with the maximum time is considered the latest. In cases where two updates have the same checkpoint time, the update that appears later in the input is considered the latest.
Formally, given a list of updates \(U = [(id_1, t_1, s_1), (id_2, t_2, s_2), \ldots, (id_n, t_n, s_n)]\), where time \(t\) is in the format \(HH:MM\), compute the result \(R\) such that:
[ R = {(id, s) \mid s \text{ is the status associated with the maximum } t \text{ for each } id }]
Output the results sorted by package ID in increasing order.
inputFormat
The first line of input contains a single integer \(n\) representing the number of updates. Each of the following \(n\) lines contains an update record in the format:
package_id checkpoint_time status
where:
package_id
is an integer.checkpoint_time
is given in the \(HH:MM\) format (24-hour clock).status
is a string that may contain spaces.
outputFormat
For each unique package_id, output a line containing the package_id and its latest status, separated by a space. The output should be sorted in ascending order of package_id.
## sample5
1 09:00 Dispatched
2 10:30 In Transit
1 11:45 Delivered
2 10:45 Out for Delivery
3 12:00 Shipped
1 Delivered
2 Out for Delivery
3 Shipped
</p>