Problem B
Einkaþjálfari
Languages
en
is
Eyþrúður has started offering gym classes as a private instructor. Each class is exactly one hour, so it’s not so complicated to make sure classes don’t overlap.
What is more complicated is tracking her available hours in a more broad sense, just to make sure she has enough time left over for sleep, errands and relaxation. Thus she now asks you to implement a computer system that she can register the classes to.
It has to support adding classes, removing classes and checking how many free hours she has between two times $T_1$ and $T_2$
Input
The first line of input contains an integer $q$, the number of queries that will follow. Next there are $q$ lines, each containing one query. Each of them starts with A, D or F. If the line starts with A a time $T$ follows, this denotes that someone wants to book a class at time $T$. If there is already a time booked at time $T$ this query should be ignored. If the line starts with D a time $T$ follows, this denotes that someone wants to remove their class at time $T$. If there is no class at time $T$ this query should be ignored. Finally if the line starts with F two times $T_1$ and $T_2$ follow. Then the program should output the number of hours from $T_1$ to $T_2$ which have not been booked, both ends being inclusive. It will always hold that $T_1 \leq T_2$.
All times in the input are at least $0$ and at most $10^9$.
Output
For each query in the input starting with F the number of available hours should be printed, as described above.
Scoring
|
Group |
Points |
Constraints |
|
1 |
20 |
$1 \leq q \leq 100$ |
|
2 |
30 |
$1 \leq q \leq 200\, 000$, at most $100$ queries starting with F |
|
3 |
50 |
$1 \leq q \leq 200\, 000$ |
| Sample Input 1 | Sample Output 1 |
|---|---|
10 A 1 A 12 A 17 A 1 F 12 17 F 3 4 D 1 D 1 F 0 100 F 12 12 |
4 2 99 0 |
