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;
void solve()
{
int n;
cin >> n;
vector<int> v(n);
for (int &i : v)
cin >> i;
map<int, int> lst;
for (int i = 0; i < n; ++i)
lst[v[i]] = i;
vector<int> ans(n);
for (int i = 0; i < n; ++i)
{
for (int j = i; j <= lst[v[i]]; ++j)
ans[j] = v[i];
i = lst[v[i]];
}
for (int i : ans)
cout << i << '\n';
}
/*
6
1 2 1 2 3 2
10
1 1 2 2 1 2 2 1 1 2
*/
signed main()
{
ios::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... |