#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 998244353
void solve()
{
ll n;
cin >> n;
vector<ll> a(n);
map<ll, ll> mp;
for (int i = 0; i < n; i++)
{
cin >> a[i];
mp[a[i]] = i;
}
for (int i = 0; i < n;)
{
ll x = a[i];
while (i < n and i <= mp[x])
{
cout << x << '\n';
i++;
}
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tests = 1;
// cin >> tests;
for (int i = 1; i <= tests; i++)
{
// cout << "Case #" << i << ": ";
solve();
}
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... |