#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>> st;
map<int,int> mp;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
int inp;
cin>>inp;
if(mp[inp]!=0){
while(!st.empty() && st.back().first!=inp){
mp[st.back().first]--;
st.pop_back();
}
}
st.push_back({inp,i});
mp[inp]++;
}
st.push_back({INT_MAX,n+1});
for(int i=0;i<st.size();i++){
if(i==st.size()-1) break;
for(int j=st[i].second;j<st[i+1].second;j++){
cout<<st[i].first <<"\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... |