#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(a) a.begin(), a.end()
#define endl "\n"
void printVector(vector<int> a){
for (auto x: a) cout << x << " ";
cout << endl;
}
void solve(){
int n; cin >> n;
vector<int> a(n);
FOR(i,0,n) cin >> a[i];
map<int, int> last;
FOR(i,0,n){
last[a[i]] = i;
}
int o = 0;
while (o < n){
int e = last[a[o]];
FOR(i,o,e){
a[i] = a[o];
}
o = e+1;
}
printVector(a);
}
int32_t main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
int t = 1; // cin >> t;
while (t--) 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... |