Submission #768763

#TimeUsernameProblemLanguageResultExecution timeMemory
768763NintsiChkhaidzeStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
176 ms14372 KiB
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define s second
#define f first
#define left (node<<1),l,((l+r)>>1)
#define right ((node<<1)|1),((l+r)>>1) + 1,r
// #define int ll 
using namespace std;

const int N = 2e5 + 5;

int a[N];
map <int,int> id;

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	
	int n;
	cin >> n;
	for (int i= 1; i <= n; i++){
		cin>>a[i];
		id[a[i]] = max(id[a[i]],i);
	}
	
	for (int i = 1; i <= n; i++){
		for (int j = i; j <= id[a[i]]; j++)
			a[j] = a[i];
		i = id[a[i]];
	}
	
	for (int i = 1; i <= n; i++)
		cout<<a[i]<<" ";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...