답안 #131907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131907 2019-07-18T03:22:07 Z Diuven Zalmoxis (BOI18_zalmoxis) C++14
100 / 100
261 ms 39820 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> S;
list<int> A;
queue<list<int>::iterator> P;

int n, k;

void comp(){
	int s = S.size();
	while(s>1 && S[s-1]==S[s-2]) S[s-2]++, s--, S.pop_back();
}

void put(int x, bool b){
	S.push_back(x); A.push_back(x);
	if(b) P.push(prev(A.end()));
	comp();
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);

	cin>>n>>k;
	for(int i=1; i<=n; i++){
		int x; cin>>x;
		if(S.empty() || S.back()>x){ put(x,0); continue; }
		while(S.back()<x) put(S.back(),1);
		put(x,0);
	}
	while(S.back()!=30) put(S.back(),1);
	while(int(A.size())<n+k){
		auto it = P.front();
		if(*it==0){ P.pop(); continue; }
		(*it)--, P.push(A.insert(it, *it));
	}
	for(int x:A) cout<<x<<' ';

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 239 ms 35744 KB Output is correct
2 Correct 244 ms 35832 KB Output is correct
3 Correct 238 ms 35824 KB Output is correct
4 Correct 241 ms 35808 KB Output is correct
5 Correct 261 ms 35832 KB Output is correct
6 Correct 248 ms 35832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 239 ms 35892 KB Output is correct
2 Correct 247 ms 35832 KB Output is correct
3 Correct 250 ms 35860 KB Output is correct
4 Correct 241 ms 35832 KB Output is correct
5 Correct 241 ms 35988 KB Output is correct
6 Correct 238 ms 35876 KB Output is correct
7 Correct 239 ms 35832 KB Output is correct
8 Correct 238 ms 36056 KB Output is correct
9 Correct 235 ms 36884 KB Output is correct
10 Correct 193 ms 39160 KB Output is correct
11 Correct 207 ms 38264 KB Output is correct
12 Correct 173 ms 39820 KB Output is correct
13 Correct 168 ms 39816 KB Output is correct
14 Correct 167 ms 39692 KB Output is correct