# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
862117 | Hanksburger | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 147 ms | 15308 KiB |
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;
vector<pair<int, int> > vec;
map<int, int> mp;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i=1; i<=n; i++)
{
int x;
cin >> x;
if (mp[x])
{
int sum=0;
while (vec.back().first!=x)
{
sum+=vec.back().second;
mp[vec.back().first]--;
vec.pop_back();
}
vec.back().second+=sum+1;
}
else
{
vec.push_back({x, 1});
mp[x]++;
}
}
for (int i=0; i<vec.size(); i++)
for (int j=0; j<vec[i].second; j++)
cout << vec[i].first << '\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |