BOJ 2493: 탑 작성일 2020-02-23 https://www.acmicpc.net/problem/2493 2월동안 187문제 풀기(지난달 누적 87개) (59/187) 아주 전형적인 스택문제. 이전 top 보다 작은거는 고려대상이 아님 12345678910111213141516171819#include <bits/stdc++.h> using namespace std; //FIO fio io; int N, x, INF=2e9; vector<pair<int,int>> st; int main() { N = io.readInt(); st.push_back({INF, 0}); for(int i = 1; i <= N; i++) { x = io.readInt(); while (st.back().first < x) st.pop_back(); cout << st.back().second << ' '; st.push_back({x,i}); } }