#C3814. Task Prioritization
Task Prioritization
Task Prioritization
In this problem, you are given a list of tasks along with their priorities. Your task is to reorder the list of tasks in descending order based on their priority. In the event that two or more tasks have the same priority, they must retain the order in which they were provided in the input.
Let \( p_i \) denote the priority of the \( i \)-th task, and let \( i \) represent its original position. You must order the tasks such that for any two tasks \( a \) and \( b \), if \( p_a > p_b \) then \( a \) appears before \( b \), and if \( p_a = p_b \), then the task with a smaller original index comes first.
inputFormat
The input consists of multiple lines.
- The first line contains a positive integer \( N \) representing the number of tasks.
- Each of the following \( N \) lines contains a task identifier (a string without spaces) and an integer representing the task's priority. The two values are separated by a space.
outputFormat
Output the identifiers of the tasks in the required sorted order, each on a new line.
## sample4
task1 10
task2 5
task3 12
task4 5
task3
task1
task2
task4
</p>