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>
#define int long long
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
signed main(){
int n;
cin>>n;
vector<int> v(n);
for(int &i:v) cin>>i;
vector<int> num=v;
sort(num.begin(),num.end());
num.resize(unique(num.begin(),num.end())-num.begin());
for(int &i:v) i=lower_bound(num.begin(),num.end(),i)-num.begin();
vector<int> cnt(n);
for(int i:v) cnt[i]++;
int pre=v[0];
for(int i=0;i<n;i++){
cnt[v[i]]--;
if(cnt[pre]==0) pre=v[i];
cout<<num[pre]<<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... |