#C427. Traffic Monitoring System
Traffic Monitoring System
Traffic Monitoring System
You are given a series of queries that simulate a traffic monitoring system. There are two types of queries:
- R t: Record a vehicle passing at time t.
- Q S E: Query the number of vehicles whose recorded timestamps t satisfy the inequality \( S \le t \le E \).
The queries are given in order. For each query of type Q
, you need to print the count of vehicles recorded so far that lie within the given range.
Example:
Input: 6 R 5 R 10 R 15 Q 1 10 Q 10 15 Q 5 20</p>Output: 2 2 3
Note: All input should be read from stdin
and all output should be written to stdout
.
inputFormat
The first line contains a single integer n indicating the number of queries. The following n lines each contain a query, which can be in one of the following formats:
R t
: Record a vehicle with timestamp t (an integer).Q S E
: Query the number of vehicles with timestamp t satisfying \( S \le t \le E \).
outputFormat
For each query of type Q
, output a single line containing the count of vehicles within the specified range.
6
R 5
R 10
R 15
Q 1 10
Q 10 15
Q 5 20
2
2
3
</p>