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 fn(n) for(int i=1; i<=n; i++)
using namespace std;
using ll=long long;
int n;
int a[200002];
vector<int> pos[200002];
void nhap(){
cin >> n;
for(int i=1; i<=n; i++){
cin >> a[i];
}
}
void solve(){
for(int i=1; i<=n; i++){
if(pos[a[i]].size()!=0){
for(int j=i-1; j>pos[a[i]].back(); j--){
a[j]=a[i];
if(pos[j].size() && j==pos[j].back()){
pos[j].pop_back();
}
}
}
pos[a[i]].push_back(i);
}
for(int i=1; i<=n; i++){
cout << a[i] << ' ';
}
cout << '\n';
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
nhap();
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |