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