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;
#define nl '\n'
int main() {
cin.tie(0)->sync_with_stdio(0);
int N; cin >> N;
vector<int> A(N); for(auto& x : A) cin >> x;
map<int, int> mx; for(int i = 0; i < N; i++) mx[A[i]] = max(mx[A[i]], i);
vector<int> ans(N);
for(int i = 0; i < N; i++) {
int nxt = mx[A[i]];
for(int j = i; j <= nxt; j++) ans[j] = A[i];
i = nxt;
}
for(auto x : ans) cout << x << nl;
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... |