기사들이 방문 시작 시각과 소요 시간을 등록하거나 취소할 때, 시각 t에 도착한 키비니가 얼마나 기다려야 하는지 각 질의마다 출력한다.
어려움8세그먼트 트리누적 합이분 탐색수학아직 제출이 없습니다시간 제한2초메모리 제한512 MBKing Kog got annoyed of the usual laxity of his knights — they can break into his hall without prior notice! Thus, the King decided to build a reception with a queue where each knight chooses in advance the time when he will come and how long the visit will take. The knights are served in the order of the recorded time, but each knight has to wait until the visits of all the knights before him are finished.
Princess Keabeanie wants to see her father. However, she does not want to interrupt the knights so she joins the queue. Unfortunately, the knights change their minds very often — they can join the queue or cancel their visits. Please help the princess to understand how long she will have to wait until she sees her father if she enters the queue at the specified moments of time given the records at the reception.
The first line of the input contains a single integer q (1 ≤ q ≤ 3 · 105) — the number of events. An event can be of three types: join, cancel, or query.
It is guaranteed that after each event there are no two knights with the same entrance time in the queue. Cancel events refer to the previous joins that were not cancelled yet.
Keabeanie can come at the same time as some knight, but Keabeanie is very polite and she will wait for the knight to pass.
For each query write a separate line with the amount of time Keabeanie will have to wait.