Advertisement
Alexvans

Untitled

Aug 29th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. #define MAX 10002
  7.  
  8. int main() {
  9.     ios_base::sync_with_stdio(0);
  10.     cin.tie(0);
  11.     cout.tie(0);
  12.  
  13.     int n, tope = 0;
  14.     cin >> n;
  15.     int v[MAX];
  16.  
  17.     for(int i = 0; i < n; i++) {
  18.         int op;
  19.         cin >> op;
  20.  
  21.         if(op == 0) {
  22.             sort(v, v + tope);
  23.             for(int it = 0; it < tope; it++)
  24.                 cout << v[it] << " ";
  25.             cout << "\n";
  26.         }
  27.         else if(op == 1) {  //Agregar
  28.             int test;
  29.             cin >> test;
  30.             v[tope] = test;
  31.             tope++;
  32.         }
  33.         else {  //Borrar
  34.             int test;
  35.             cin >> test;
  36.             int idx = lower_bound(v, v + tope, test) - v;
  37.             v[idx] = (1<<30);
  38.             sort(v, v + tope);
  39.             tope--;
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement