This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |