제출 #922026

#제출 시각아이디문제언어결과실행 시간메모리
922026TAhmed33Stone Arranging 2 (JOI23_ho_t1)C++98
100 / 100
185 ms17744 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 25; int a[MAXN], n; int main () { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; stack <array <int, 3>> cur; map <int, int> dd; for (int i = 1; i <= n; i++) { array <int, 3> l = {a[i], i, i}; if (dd[a[i]]) { while (cur.top()[0] != a[i]) { l[1] = cur.top()[1]; dd[cur.top()[0]]--; cur.pop(); } } dd[a[i]]++; cur.push(l); } int ans[n + 1] = {}; while (!cur.empty()) { for (int i = cur.top()[1]; i <= cur.top()[2]; i++) ans[i] = cur.top()[0]; cur.pop(); } for (int i = 1; i <= n; i++) cout << ans[i] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...