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;
#define all(x) (x).begin(), (x).end()
int main() {
cin.tie(0)->sync_with_stdio(false);
int n;
cin >> n;
map<int, int> cnt;
vector<array<int, 2>> a;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
int cur = 1;
if (cnt[x]) {
while (a.back()[0] != x) {
cur += a.back()[1];
cnt[a.back()[0]]--;
a.pop_back();
}
}
cnt[x]++;
a.push_back({x, cur});
}
for (auto &[x, c] : a)
while (c--)
cout << x << '\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... |