제출 #1204873

#제출 시각아이디문제언어결과실행 시간메모리
1204873namhhStone Arranging 2 (JOI23_ho_t1)C++20
0 / 100
0 ms328 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+1;
int n,a[N],ans[N],pre[N];
unordered_map<int,int>mp;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(mp[a[i]] == 0) pre[i] = i;
		else pre[i] = mp[a[i]];
		mp[a[i]] = i;
	}
	int x = n;
	while(x > 0){
		int cc = pre[x];
		for(int i = cc; i <= x; i++) ans[i] = a[x];
		x = cc-1;
	}
	for(int i = 1; i <= n; i++) cout << ans[i] << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...