#K41187. Event Processing Order
Event Processing Order
Event Processing Order
You are given a list of events. Each event is represented by a unique id and an associated priority value. Your task is to process these events in order such that events with higher priority are processed first. When two events have the same priority, they must be processed in the same order as they appear in the input.
For example, if the input consists of 5 events:
1 3 2 1 3 2 4 3 5 1
Then the processing order of event ids should be:
1 4 3 2 5
This problem will test your understanding of sorting with stability and handling input/output via stdin and stdout.
inputFormat
The first line of the input contains a single integer n (0 ≤ n ≤ 105), the number of events.
The following n lines each contain two integers: the event id and its priority. The id is a unique integer, and priority is an integer value that can be positive, zero, or negative.
outputFormat
Output a single line containing the event ids in the order they are processed, separated by a space.
## sample5
1 3
2 1
3 2
4 3
5 1
1 4 3 2 5
</p>