#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (auto &i: a) cin >> i;
// solve
map<int, int> rightmost;
for (int i = 0; i < n; i++) rightmost[a[i]] = i;
vector<int> ans(n);
int curpos = 0;
while (curpos != n) {
int color = a[curpos];
for (; curpos <= rightmost[color]; curpos++) ans[curpos] = color;
}
// ans
for (int i: ans) cout << i << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
// cin >> t;
while (t--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |