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 ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
const int maxn=1000005;
int n,a[maxn];
map <int,int> r;
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
for(int i=0;i<n;i++){
cin >> a[i];
r[a[i]]=i;
}
for(int i=0;i<n;i++){
if(i==r[a[i]]) continue;
for(int j=i+1;j<r[a[i]];j++) a[j]=a[i];
i=r[a[i]];
}
for(int i=0;i<n;i++) cout << a[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... |