제출 #1055371

#제출 시각아이디문제언어결과실행 시간메모리
1055371fryingducStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
52 ms6864 KiB
#include "bits/stdc++.h" using namespace std; const int maxn = 2e5 + 5; int n, a[maxn]; int mx[maxn]; void solve() { cin >> n; vector<int> v; for(int i = 1; i <= n; ++i) { cin >> a[i]; v.push_back(a[i]); } sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); for(int i = 1; i <= n; ++i) { a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1; mx[a[i]] = max(mx[a[i]], i); } for(int i = 1; i <= n; ++i) { int j = mx[a[i]]; while(i < j) { a[i] = a[j]; ++i; } } for(int i = 1; i <= n; ++i) { cout << v[a[i] - 1] << '\n'; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...