Submission #1036813

#TimeUsernameProblemLanguageResultExecution timeMemory
1036813ivazivaStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
398 ms19988 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...