#K71837. Final Location Determination
Final Location Determination
Final Location Determination
In this problem, you are given a series of movements representing people's location updates. Each movement is given as a pair of an integer ID and a location string. A person may appear multiple times; in that case, only the last location is considered. Your task is to determine the final location of each person, and then output the results sorted in ascending order by ID.
The input begins with an integer (n) denoting the number of movements. The next (n) lines each contain a movement with the following format:
(ID) followed by a space, then the (LOCATION) (which may contain spaces) representing the new location. The output should list each unique person’s ID and their final location, one per line, formatted as "ID LOCATION".
inputFormat
The first line of input contains a single integer (n) representing the number of movements. Each of the following (n) lines contains a movement record. Each record starts with an integer ID followed by a space and then a string LOCATION, which may consist of multiple words.
outputFormat
For each unique person ID, output a line containing the ID and the final LOCATION (i.e. the last location provided for that ID). The results must be sorted in ascending order by the ID.## sample
5
1 Hogwarts
2 Hogsmeade
1 Forbidden Forest
3 Great Hall
2 Quidditch Pitch
1 Forbidden Forest
2 Quidditch Pitch
3 Great Hall
</p>