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;
using ll = long long;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin>>n;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++){
cin>>a[i];
}
map<int, int> mp;
vector<int> p(n + 1);
for (int i = 1; i <= n; i++){
if (mp.find(a[i]) != mp.end()){
p[i] = mp[a[i]];
}
mp[a[i]] = i;
}
int r = 0;
for (int i = 1; i <= n; i++){
if (p[i] > r){
for (int j = p[i]; j < i; j++){
a[j] = a[i];
}
r = i;
}
}
for (int i = 1; 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... |