fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <vector>
  6. #include <unordered_map>
  7. #include <iomanip>
  8. #include <stack>
  9. #include <queue>
  10. #include <deque>
  11. #define uwf(name) if(fopen(name".inp","r")){freopen(name".inp","r",stdin);freopen(name".out","w",stdout);}
  12. #define zukkyng int main()
  13. #define f first
  14. #define s second
  15. #define riel_pragma ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  16. #define ll long long
  17. #define pii pair<int,int>
  18. using namespace std;
  19. /*
  20.   this code was written by zukkyng/AlephZ from ILS(2024-2027)
  21. */
  22.  
  23. stack<int> mmb;
  24. stack<int> bmg;
  25. zukkyng
  26. {
  27. int n,dir,x;
  28. cin>>n;
  29. while (n--)
  30. {
  31. cin>>dir;
  32. if (dir==1)
  33. {
  34. cin>>x;
  35. mmb.push(x);
  36. if (bmg.empty()) bmg.push(x);
  37. else
  38. {
  39. if (x>bmg.top()) bmg.push(x);
  40. }
  41. }
  42. if (dir==2)
  43. {
  44. if (mmb.top()==bmg.top()) bmg.pop();
  45. mmb.pop();
  46. }
  47. if (dir==3) cout<<bmg.top()<<'\n';
  48. }
  49. }
  50.  
Success #stdin #stdout 0s 5284KB
stdin
10
1 97
2
1 20
2
1 26
1 20
2
3
1 91
3
stdout
26
91