Status: | Past | Start: | 2018-10-06 12:30:00 | End: | 2018-10-06 16:30:00 |
The 2018 ACM-ICPC Caribbean National Contests (Real Contest)
Problem
4076 - Add and Count with Sets
Created by | Rubén Alcolea Núñez |
Added by | ymondelo20 (2018-09-05) |
Limits |
Total Time: 10000 MS
|
Test Time:
1000 MS
|Memory: 512 MB | Output: 64 MB | Size:
16 KB
|
Enabled languages | |
Available in |
![]() ![]() |
Description
In this problem we are interested in maintaining a set of integers that supports two operations:
- add(x): add a number x (1 ≤ x ≤ 106) to the set.
- count(a, b): count the number of elements within the range [a, b] (1 ≤ a ≤ b ≤ 106).
En este problema se desea mantener un conjunto de enteros que soporta dos operaciones:
- add(x): Adiciona el número x (1 ≤ x ≤ 1000000) al conjunto.
- count(a, b): Contar el número de elementos en el rango [a, b] (1 ≤ a ≤ b ≤ 1000000).
In this problem we are interested in maintaining a set of integers that supports two operations:
- add(x): add a number x (1 ≤ x ≤ 106) to the set.
- count(a, b): count the number of elements within the range [a, b] (1 ≤ a ≤ b ≤ 106).
Input specification
The input contains in the first line an integer Q (1 ≤ Q ≤ 2 × 105), the number of queries. The following Q lines have the information of each query, as explained above.
La entrada contiene en la primera línea un entero Q (1 ≤ Q ≤ 200000), el número de consultas. Las siguientes Q líneas contienen la información de cada consulta, tal y como se explicó anteriormente.
The input contains in the first line an integer Q (1 ≤ Q ≤ 2 × 105), the number of queries. The following Q lines have the information of each query, as explained above.
Output specification
For each query of type 2, output the answer in a single line.
Para cada consulta de tipo 2, imprima la respuesta en una línea.
The input contains in the first line an integer Q (1 ≤ Q ≤ 2 × 105), the number of queries. The following Q lines have the information of each query, as explained above.
Sample input
7
1 1
1 5
1 10
1 1
1 5
2 1 5
2 5 20
Sample output
4
3