Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- using namespace std;
- int main()
- {
- /**
- Vienen Q consultas (1 <= Q <= 100.000)
- La consulta de tipo A nos da un número
- para agregar a una lista
- La consulta de tipo B nos da un número
- y tenemos que decir si existe en la lista
- que tenemos hasta el momento
- **/
- /**
- 10
- A 7
- A 4
- B 5
- A 5
- B 6
- A 1000000
- B 999
- B 1000000
- A 999
- B 999
- C 999
- NO
- NO
- NO
- SI
- SI
- **/
- set <int> lista;
- lista.insert(10);
- lista.insert(10);
- int cantidad = lista.count(10);
- int Q;
- cin >> Q;
- for(int i=0; i<Q; i++)
- {
- char tipo;
- int valor;
- cin >> tipo >> valor;
- if(tipo == 'A')
- {
- lista.insert(valor); ///log(lista.size())
- }
- else if(tipo == 'B')
- {
- if(lista.count(valor) == 0) ///log(lista.size())
- {
- cout << "NO" << endl;
- }
- else
- {
- cout << "SI" << endl;
- }
- }
- else
- {
- if(lista.count(valor) == 0)
- {
- cout << "No existe, no se puede borrar" << endl;
- }
- else
- {
- lista.erase(lista.find(valor));
- }
- }
- }
- ///Q*log(Q)
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement