제출 #781727

#제출 시각아이디문제언어결과실행 시간메모리
781727borisAngelovStone Arranging 2 (JOI23_ho_t1)C++17
35 / 100
27 ms2776 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; int n; int a[maxn]; unordered_map<int, vector<int>> last; void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { if (last.find(a[i]) != last.end() && !last[a[i]].empty()) { for (int j = last[a[i]].back() + 1; j <= i - 1; ++j) { last[a[j]].pop_back(); if (last[a[j]].empty()) { last.erase(a[j]); } a[j] = a[i]; } } last[a[i]].push_back(i); } //cout << "--------------------------" << endl; for (int i = 1; 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...