# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
769058 | danikoynov | Stone Arranging 2 (JOI23_ho_t1) | C++14 | 221 ms | 19144 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>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 2e5 + 10;
int n, a[maxn], b[maxn];
map < int, pair < int, int > > mp;
void solve()
{
cin >> n;
for (int i = 1; i <= n; i ++)
cin >> a[i];
stack < int > st;
for (int i = 1; i <= n; i ++)
{
if (mp[a[i]].first == 0)
{
mp[a[i]] = {i, i};
st.push(a[i]);
continue;
}
while(st.top() != a[i])
{
mp[st.top()] = {0, 0};
st.pop();
}
mp[a[i]].second = i;
}
for (pair < int, pair < int, int > > cur : mp)
{
for (int i = cur.second.first; i <= cur.second.second; i ++)
b[i] = cur.first;
}
for (int i = 1; i <= n; i ++)
cout << b[i] << endl;
}
int main()
{
solve();
return 0;
}
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... |