Advertisement
jw910731

Sprout-48(WA)

Mar 21st, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #ifdef ONLINE_JUDGE
  3. #define _ //std::ios::sync_with_stdio(0);std::cin.tie(0);
  4. #elif TEST
  5. #define _ printf("###TESTING###\n");
  6. #else
  7. #define _
  8. #endif
  9. using namespace std;
  10. /************************/
  11. #define MAX 2000
  12. #define INF 1000000000
  13. int main(){ _
  14.     int stak[MAX+5],top=0,tmp;
  15.     stak[top++] = INF;
  16.     while(scanf("%d",&tmp)!=EOF){
  17.         if(top<2){
  18.             stak[top++] = tmp;
  19.             continue;
  20.         }
  21.         while(tmp > stak[top-2] && tmp > stak[top-1]){
  22.             printf("%d\n", stak[--top]);
  23.         }
  24.         stak[top++] = tmp;
  25.     }
  26.     while(top > 1)printf("%d\n", stak[--top]);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement