제출 #990858

#제출 시각아이디문제언어결과실행 시간메모리
990858yanbStone Arranging 2 (JOI23_ho_t1)C++14
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> nxt(n); map<int, int> last; for (int i = n - 1; i >= 0; i--) { nxt[i] = (last[a[i]] ? last[a[i]] : -1); last[a[i]] = i; } int i = 0; while (i < n) { int x = i; for (; i < nxt[x]; i++) { a[i] = a[x]; } i++; } for (int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...