Advertisement
anon20016

N

Nov 16th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #define _CRT_SECURE_NO_DEPRECATE
  2.  
  3. #include <iostream>
  4. #include <vector>
  5. #include <string>
  6. #include <map>
  7. #include <set>
  8. #include <algorithm>
  9.  
  10. #define li long long
  11.  
  12. using namespace std;
  13.  
  14. int main() {
  15. int n;
  16. cin >> n;
  17. multiset<int> a;
  18. for (int i = 0; i < n; i++) {
  19. int c;
  20. cin >> c;
  21. if (c == 0) {
  22. cout << *a.begin() << endl;
  23. a.erase(a.begin());
  24. }
  25. else {
  26. a.insert(c);
  27. }
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement