#P4511. [CTSC2015] 日程管理
[CTSC2015] 日程管理
Description
Youxiang is a very influential person in Gensokyo. She handles a huge number of affairs every day, and it has become hard for her to manage them all. Therefore, she decides to develop a schedule management program to help manage her tasks.
For each task , there is a deadline and a profit . If Youxiang finishes this task no later than day , she will obtain a profit of . Youxiang is very capable and can finish any task in exactly one day. However, since there are so many tasks, she cannot always complete all of them. She wants to know, in such cases, what the maximum total profit she can obtain is.
Since people in Gensokyo are fickle, tasks keep changing. Youxiang wants this management program to support inserting a task and deleting a task.
Specifically, the program should support the following 2 operations:
ADD t p: Insert a new task with deadline and profit .DEL t p: Delete one task with deadline and profit . If multiple such tasks exist, delete exactly one. It is guaranteed that such a task exists.
After each operation is executed, you need to output the maximum total profit achievable by completing tasks.
Youxiang has days to schedule, from day to day . Can you help her write this efficient program?
Input Format
The first line contains two integers and , denoting the number of days and the number of operations.
The next lines describe the operations. The -th line is the -th operation, in the form ADD t p or DEL t p, with meanings as described above.
Output Format
For each operation, output one integer: the maximum total profit Youxiang can obtain after that operation is performed.
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
5811
10843
5811
11361
14847
9036
3486
8602
18165
18259
Hint
It is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号