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;
void solve(){
int N; cin >> N;
vector<int> a(N);
for(int i = 0; i < N; i ++) cin >> a[i];
vector<int> ans(N);
map<int, int> mp;
for(int i = 0; i < N; i ++) mp[a[i]] = max(mp[a[i]], i);
int curpos = 0;
while(curpos != N){
int nextpos = mp[a[curpos]] + 1;
for(int i = curpos; i < nextpos; i ++) ans[i] = a[curpos];
curpos = nextpos;
}
for(int i = 0; i < N; i ++) cout << ans[i] << '\n';
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
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... |