fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <stack>
  4. #include <algorithm>
  5. #include <string.h>
  6. using namespace std;
  7. stack <int> s;
  8. int n,a,x,res;
  9. int main() {
  10. scanf("%d",&n);
  11. for(int i=0;i<n;i++){
  12. scanf("%d",&a);
  13. if(a==1){
  14. scanf("%d",&x);
  15. s.push(min(x,s.top()));
  16. }
  17. else if(a==2){
  18. s.pop();
  19. }
  20. else {
  21. printf("%d\n",s.top());
  22. }
  23. }
  24. }
Runtime error #stdin #stdout 0s 15240KB
stdin
8
1 2
1 3
1 -3
3
2
3
2
3
stdout
Standard output is empty