Submission #1281742

#TimeUsernameProblemLanguageResultExecution timeMemory
1281742AbdullahIshfaqStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
264 ms16592 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...