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>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define abcorz ios_base::sync_with_stdio(false);cin.tie(0);
int32_t main(){
abcorz;
int n;cin>>n;
vector<int> v(n);
vector<int> a[n];
vector<int> t;
for(int i=0;i<n;i++){
cin>>v[i];
t.push_back(v[i]);
}
sort(all(t));
t.resize(unique(all(t))-t.begin());
for(int i=0;i<n;i++){
v[i]=lower_bound(all(t),v[i])-t.begin();
a[v[i]].push_back(i);
}
int i=0;
while(i<n){
int sz=a[v[i]].size();
if(sz>1){
for(int j=i;j<a[v[i]][sz-1];j++){
v[j]=v[i];
}
i=a[v[i]][sz-1];
}
i++;
}
for(int i=0;i<n;i++){
cout<<t[v[i]]<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |