Segments
Easy
Execution time limit is 1 second
Runtime memory usage limit is 256 megabytes
Consider a real axis and segments on it. You are to write a program that processes queries of two kinds.
Query '+ L R' adds a segment from point L to point R. You program should print the number of segments that are (non-strictly) inside the new one.
Query '- L R' removes one segment from point L to point R. If there is no such segment, ignore this query.
You may assume that no more than 1000 segments will present on the axis simultaneously.
Input
Each line contains one query. Query can be in the form '- L R' or '+ L R' where L and R are integers (-10^9
≤ L < R ≤ 10^9
). There will be no more than 250 000 queries.
Output
Print to the output one line for each '+ L R' query, containing the number of segments inside the added segment.
Examples
Input #1
Answer #1
Submissions 19
Acceptance rate 53%