난이도: G4 문제풀이 : stack 이용 #include #include #include using namespace std; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; stack stk; vector res(n, -1); int x; for (int i = 0; i > x; while (!stk.empty() && stk.top().second < x) { res[stk.top().first] = x; stk.pop(); } stk.push({i, x}); } for (auto v : res) cout