https://www.acmicpc.net/problem/1874아이디어push 시 1~n 순서대로 넣어야 하기 때문에 어느 값까지 넣었는지 pushed에 담았다.스택 안 정해진 순서대로 pop되어야 하는 것을 고려했다.