#include <bits/stdc++.h>
using namespace std;
const int K = 1e6 + 5;
int n, k, acum, v[K];
vector<int> deBagat[K];
void trie(int nr) {
	if (v[acum] == nr) {
		acum ++;
		return;
	}
	trie(nr - 1);
	if (acum > n || v[acum] > nr - 1) {
		k --;
		deBagat[acum - 1].push_back(nr - 1);
		return;
	}
	trie(nr - 1);
}
void print(int nr) {
	if (k == 0) {
		cout << nr << " ";
		return;
	}
	k --; //am bucla infinita lol
	print(nr - 1), print(nr - 1);
}
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i ++)
        cin >> v[i];
	acum = 1;
	trie(30);
	for (int i = 1; i <= n; i ++) {
		cout << v[i] << " ";
		for (auto j : deBagat[i])
			print(j);
	}
	cout << '\n';
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |