#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
const int N = 200000;
int aa[N], kk[N];
map<int, bool> used;
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
int n; cin >> n;
int m = 0;
while (n--) {
int a; cin >> a;
if (!used[a]) {
aa[m] = a;
kk[m] = 1;
m++;
used[a] = true;
continue;
}
int s = 1;
while (aa[m - 1] != a)
used[aa[m - 1]] = false, s += kk[--m];
kk[m - 1] += s;
}
for (int h = 0; h < m; h++)
while (kk[h]--)
cout << aa[h] << '\n';
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |