Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #ifdef ONLINE_JUDGE
- #define _ //std::ios::sync_with_stdio(0);std::cin.tie(0);
- #elif TEST
- #define _ printf("###TESTING###\n");
- #else
- #define _
- #endif
- using namespace std;
- /************************/
- #define MAX 2000
- #define INF 1000000000
- int main(){ _
- int stak[MAX+5],top=0,tmp;
- stak[top++] = INF;
- while(scanf("%d",&tmp)!=EOF){
- if(top<2){
- stak[top++] = tmp;
- continue;
- }
- while(tmp > stak[top-2] && tmp > stak[top-1]){
- printf("%d\n", stak[--top]);
- }
- stak[top++] = tmp;
- }
- while(top > 1)printf("%d\n", stak[--top]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement