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;
long long n, a[200001], ans[200001];
map<int, int> pre;
int main()
{
cin >> n;
for(int i = 1; i <= n; ++i)
{
cin >> a[i];
pre[a[i]] = 0;
}
for(int i = n; i >= 1; --i)
{
if(!pre[a[i]]) pre[a[i]] = i;
}
for(int i = 1; i <= n; i = pre[a[i]] + 1)
{
for(int j = i; j <= pre[a[i]]; ++j)
{
ans[j] = a[i];
}
}
for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |