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 = 1; i <= N; i ++) cin >> A[i];
map<int, int> mp;
for(int i = 1; i <= N; i ++) mp[A[i]] = max(mp[A[i]], i);
vector<int> answer(N);
int curpos = 1;
for(auto i : mp){
if(curpos >= N) break;
for(int j = curpos; j <= i.second; j ++) answer[j] = i.first;
curpos = i.second + 1;
}
for(int i = 1; i <= N; i ++) cout << answer[i] << endl;
}
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... |