This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
_ _ __ _ _ _ _ _ _
|a ||t ||o d | |o |
| __ _| | _ | __| _ |
| __ |/_ | __ /__\ / _\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
vector <pair <int, int>> v;
map <int, int> cnt;
for (int i = 0; i < N; i++) {
int x;
cin >> x;
cnt[x]++;
if (cnt[x] > 1) {
while (v.back().first != x) {
cnt[v.back().first] -= v.back().second;
cnt[x] += v.back().second;
v.pop_back();
}
v.back().second = cnt[x];
} else {
v.push_back(make_pair(x, 1));
}
}
for (pair <int, int> p : v) {
for (int i = 0; i < p.second; i++) {
cout << p.first << "\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... |