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::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n;
cin >> n;
map<int, vector<int>> st;
int a[n];
for(int i = 0; i < n; i++) {
cin >> a[i];
if(st[a[i]].empty()) st[a[i]].push_back(i);
else {
int lst = st[a[i]].back();
for(int j = i - 1; j > lst; j--)
st[a[j]].pop_back();
while(lst < i) {
a[++lst] = a[i];
st[a[lst]].push_back(lst);
}
}
}
for(int i = 0; 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... |