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 n,a[200005];
map<int,bool>am;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
vector<pair<int,int>>v;
for (int i = 1; i <= n; i++)
{
if (!am[a[i]])
{
am[a[i]] = true;
v.push_back({a[i],1});
}
else
{
int cate = 1;
while (v.back().first != a[i])
{
cate += v.back().second;
am[v.back().first] = false;
v.pop_back();
}
v[v.size() - 1].second += cate;
}
}
for (auto it : v)
for (int i = 1; i <= it.second; i++)
cout << it.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... |