Loading environment...
Wow, your to-do list is empty... but not for long! Over the next few seconds, you'll have to handle updates to your to-do list.
For the first type of update, you will have to add a new homework assignment to your to-do list. This assignment will be released at the beginning of second , and will take seconds to complete (). For the second type of update you will have to remove the -th homework assignment that was added to your to-do list.
After each update, you wonder: what's the earliest time you can finish all of the homework assignments in your to-do list? You can only work on one assignment at a time, and you must finish a homework assignment once you start it without switching to another assignment.
The first line of input contains an integer .
The next lines each contain a line starting with a character or . A line starting with represents the first type of update and ends with two space-separated encrypted* integers and . A line starting with represents the second type of update and ends with an encrypted integer . It is guaranteed that there have been at least assignments added and that the -th assignment to be added has not been removed yet.
It is guaranteed that there is at least one homework assignment on your to-do list after every update.
The following table shows how the available 15 marks are distributed:
| Marks | Bounds on | Additional Constraints |
|---|---|---|
| 2 | None | |
| 6 | Only updates of the first type | |
| 7 | None |
*Note that the input for this problem is encrypted. To decrypt and obtain the actual values of , , and , you may use the following formulas:
Here, represents the answer after the previous update and is initially before any updates. It may also be useful to note that corresponds to the % operator in most programming languages, indicating the remainder after division. For example, and .
Output lines, where the -th line contains the earliest time (in seconds) you can finish all of the homework assignments in your to-do list after the -th update.
The unencrypted sample input is provided for ease of reference.
After the first update, we can start the first assignment at the beginning of second 3 and finish at the end of second 5 (interval [3, 5]).
After the second update, we can do the first assignment over the interval [3, 5] and the second assignment over the interval [7, 11].
After the third update, we can do the first assignment over the interval [3, 5], the third assignment over the interval [6, 8], and then the second assignment over the interval [9, 13].
After the fourth update, we can do the third assignment over the interval [4, 6] and the second assignment over the interval [7, 11].
After the fifth update, we can do the third assignment over the interval [4, 6], the second assignment over the interval [7, 11], and the fourth assignment over the interval [12, 13].
After the sixth update, we can do the third assignment over the interval [4, 6] and the fourth assignment over the interval [8, 9].
No comments yet. Be the first to comment!