Rightsizing
InterviewTime limit5sMemory limit1024 MB
Given raises and firings in order, print the name and salary of each fired employee, the one with the highest salary at that moment (ties go to the earlier name).
Statement
Many tech companies have realized that they "over-hired". Looking at their books, they realize they might have to let go of some employees. To protect the bottom line, a company always fires the employee earning the highest annual salary at the time. If several employees share the same maximum salary, the one whose name comes first alphabetically is fired.
Employees can still get raises to keep morale up, which makes deciding whom to fire trickier.
Given a set of employees with their initial annual salaries, followed by a sequence of actions (either firing an employee or giving a raise to a current employee), determine which employee is fired at each firing event.
Input
The first line contains two integers () and (), the number of employees and the number of actions.
The next lines each contain a name and an annual salary (). Each name is unique and has 1 to 20 lowercase letters.
The next lines describe the actions. A line starting with 1 gives a raise: it is followed by a name and a raise amount (). Each employee who receives a raise is from the original list and has not been fired yet. A line starting with 2 fires the employee with the highest current salary, breaking ties by alphabetical order of name. There are at most lines starting with 2.
Output
For each firing event, print one line with the name of the fired employee and their annual salary at the time they were fired, separated by a space.