fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int q;
  6. scanf("%d", &q);
  7. multiset<int> mset;
  8. while (q--) {
  9. int t, x;
  10. scanf("%d %d", &t, &x);
  11. if (t == 1) mset.insert(x);
  12. else mset.erase(mset.find(x));
  13. printf("%d\n", mset.empty() ? -1 : *mset.begin());
  14. }
  15. return 0;
  16. }
Success #stdin #stdout 0s 15232KB
stdin
8
1 2
1 3
1 1
2 2
2 1
1 5
2 3
2 5
stdout
2
2
1
1
3
3
5
-1