제출 #857041

#제출 시각아이디문제언어결과실행 시간메모리
857041NotLinuxStone Arranging 2 (JOI23_ho_t1)C++17
35 / 100
2063 ms1112 KiB
#include <bits/stdc++.h>
using namespace std;
void solve(){
	int n,sz = 0;
	cin >> n;
	map < int , int > last;
	vector < array < int , 3 > > v;
	//cout << n << " flag" << endl;
	while(n--){
		int x;cin >> x;
		//cout << "query : " << x << endl;
		if(last.count(x)){
			//cout << "case : " << last[x] << endl;
			sz++;
			while((last[x]-1) != (int)v.size()){
				v.pop_back();
			}
			v.push_back({x,v.back()[2]+1,sz});
		}
		else{
			//cout << "case2" << endl;
			sz++;
			v.push_back({x,sz,sz});
		}
		last[x] = v.size();
		//cout << "v : ";for(auto itr : v)cout << itr[0] << "," << itr[1] << "," << itr[2] << "   ";cout << endl;
	}
	for(auto itr : v){
		for(int j = 0;j<(itr[2] - itr[1] + 1);j++){
			cout << itr[0] << '\n';
		}
	}
	cout << endl;
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int testcase = 1;//cin >> testcase;
	while(testcase--)solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...