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;
int main()
{
int n; cin >> n;
vector<int> a(n);
map<int, int> remaining;
for (int i = 0; i < n; i++) {
cin >> a[i];
remaining[a[i]]++;
}
int j = 0;
for (int i = 0; i < n - 1; i++){
j = i + 1;
remaining[a[i]]--;
if (remaining[a[i]] > 0){
while(j < n && a[j] != a[i]){
remaining[a[j]]--;
a[j] = a[i];
j++;
}
}
i = j - 1;
}
for (int i = 0; i < n; i++){
cout << a[i] << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |