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;
for (int i = n; i > 0; i--){
if (mp.find(a[i]) != mp.end()){
continue;
}
mp[a[i]] = i;
}
int i = 1;
while (i <= n){
int x = a[i], t = mp[x];
while (i <= t){
a[i++] = x;
}
}
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... |