Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <stack>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. cin.tie(0);
  8. ios_base::sync_with_stdio(0);
  9.  
  10. int n;
  11. cin >> n;
  12. stack<long long> first;
  13. stack<long long> second;
  14. long long min_elem = 100000 * 10000 + 1;
  15.  
  16. for (int i = 0; i < n; i++) {
  17. int x;
  18. cin >> x;
  19. if (x == 1) {
  20. int y;
  21. cin >> y;
  22. first.push(y);
  23. if (y <= min_elem) {
  24. min_elem = y;
  25. second.push(y);
  26. }
  27. else {
  28. second.push(min_elem);
  29. }
  30. }
  31. if (x == 2) {
  32. if (first.top() == second.top()) {
  33. second.pop();
  34. }
  35. first.pop();
  36. }
  37. if (x == 3) {
  38. cout << second.top() << endl;
  39. }
  40. }
  41.  
  42. system("pause");
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement