제출 #1176138

#제출 시각아이디문제언어결과실행 시간메모리
1176138chikien2009Stone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
187 ms14224 KiB
#include <bits/stdc++.h> using namespace std; void setup() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, a[200000], b[200000]; deque<int> pos; map<int, int> num; int main() { setup(); cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; while (num[a[i]] && !pos.empty() && a[pos.back()] != a[i]) { num[a[pos.back()]]--; pos.pop_back(); } b[i] = (pos.empty() ? -1 : pos.back()); pos.push_back(i); num[a[i]]++; } for (int i = n - 1; i >= 0;) { for (int j = i; j > b[i];--j) { a[j] = a[i]; } i = b[i]; } for (int i = 0; i < n; ++i) { cout << a[i] << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...