#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+1;
int n,a[N],ans[N],pre[N];
unordered_map<int,int>mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
if(mp[a[i]] == 0) pre[i] = i;
else pre[i] = mp[a[i]];
mp[a[i]] = i;
}
int x = n;
while(x > 0){
int cc = pre[x];
for(int i = cc; i <= x; i++) ans[i] = a[x];
x = cc-1;
}
for(int i = 1; i <= n; i++) cout << ans[i] << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |