#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef double ld;
const int INF = 1e10;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> arr(n);
for(int&i:arr)cin>>i;
set<int> arrnew;
map<int,int> idx;
for(int i=0;i<n;i++) {
if(idx.contains(arr[i])) {
while(*--arrnew.end()>idx[arr[i]])arrnew.erase(--arrnew.end());
}
idx[arr[i]]=i+1;
arrnew.insert(i+1);
}
auto iter = arrnew.begin();
int col = -1;
for(int i=1;i<=n;i++) {
if(iter!=arrnew.end() and *iter==i){col=arr[i-1];iter++;}
cout << col << '\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... |