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:
  1. add(x): add a number x (1 ≤ x ≤ 106) to the set.
  2. count(a, b): count the number of elements within the range [a, b] (1 ≤ a ≤ b ≤ 106).
Write a program to perform Q queries of type 1 or 2.
En este problema se desea mantener un conjunto de enteros que soporta dos operaciones:
  1. add(x): Adiciona el número x (1 ≤ x ≤ 1000000) al conjunto.
  2. count(a, b): Contar el número de elementos en el rango [a, b] (1 ≤ a ≤ b ≤ 1000000).
Escriba un programa para ejecutar Q consultas de tipo 1 o 2.
In this problem we are interested in maintaining a set of integers that supports two operations:
  1. add(x): add a number x (1 ≤ x ≤ 106) to the set.
  2. count(a, b): count the number of elements within the range [a, b] (1 ≤ a ≤ b ≤ 106).
Write a program to perform Q queries of type 1 or 2.

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

Hint(s)