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>
#define fi first
#define se second
const int N = 200200;
const int mod = 1e9 + 7;
using namespace std;
int main() {
#ifdef zxc
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin >> n;
vector<int> a(n);
map<int, int> last;
for (int i = 0; i < n; i++) {
cin >> a[i];
last[a[i]] = i;
}
for (int i = 0; i < n; i++) {
for (int j = i; j <= last[a[i]]; j++) {
a[j] = a[i];
}
i = last[a[i]];
}
for (int x : a) {
cout << x << "\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... |