Problem Description
There are days and multiple tasks on a calendar, each task has two attributes, a deadline , and a profit , meaning the task has to be completed by day to earn a profit of . Each task only takes one day to complete, the calendar needs to support the following two operations.
- ADD t p: Add a task with deadline t and profit p
- DEL t p: Delete the task with deadline t and profit p, if multiple exists, delete any one of those. The data gurantees at least one exists.
After every operation, output the maximum profit after days.
Input Specifications
The first line are two integers , denoting the number of days on the calendar, and the number of operations
Output Specifications
lines, each line containing the maximum profit after day after each operation.
Sample Input
5 10
ADD 1 5811
ADD 3 5032
DEL 3 5032
ADD 3 5550
ADD 5 3486
DEL 1 5811
DEL 3 5550
ADD 4 5116
ADD 3 9563
ADD 5 94
Sample Output
5811
10843
5811
11361
14847
9036
3486
8602
18165
18259
Data
Comments