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 ll long long
#define in insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define mid (l+r)/2
#define pop pop_back
//#define all(v) v.begin(),v.end()
using namespace std;
const int M=998244353;
int n,a[200001],b[200001];
map<int,vector<int>> mp;
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
mp[a[i]].pb(i);
vector<int> v=mp[a[i]];
if(v.size()>=2){
for(int j=v[v.size()-2];j<=i;j++){
b[j]=a[i];
mp[a[j]].pop();
}
}
}
for(int i=1;i<=n;i++) cout<<b[i]<<' ';
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... |