/// Preset de orice altceva
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <iomanip>
using namespace std;
//ifstream cin("test.in");
//ofstream cout("test.out");
int n, k, v[1000005], ind, diff;
vector <pair<int, bool>> sol;
vector <int> ans;
void dfs(int val)
{
if(val == -1)
return;
if(v[ind] == val)
{
ind++;
sol.push_back({val, 1});
return;
}
if(v[ind] < val)
{
dfs(val - 1);
dfs(val - 1);
}
else
sol.push_back({val, 0});
}
void afis(int val)
{
if(diff == 0 || val == 0)
{
cout << val << ' ';
return;
}
diff--;
afis(val - 1);
afis(val - 1);
}
int main()
{
cin >> n >> k;
for(int i = 1; i <= n; i++)
cin >> v[i];
v[n + 1] = 31;
ind = 1;
dfs(30);
diff = n + k - sol.size();
for(auto elem : sol)
{
if(elem.second == 1 || diff == 0)
cout << elem.first << ' ';
else
afis(elem.first);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
271 ms |
14292 KB |
Output is correct |
2 |
Correct |
236 ms |
14328 KB |
Output is correct |
3 |
Correct |
245 ms |
14168 KB |
Output is correct |
4 |
Correct |
248 ms |
14248 KB |
Output is correct |
5 |
Correct |
246 ms |
14260 KB |
Output is correct |
6 |
Correct |
236 ms |
14224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
244 ms |
14244 KB |
Output is correct |
2 |
Correct |
244 ms |
14160 KB |
Output is correct |
3 |
Correct |
257 ms |
14204 KB |
Output is correct |
4 |
Correct |
249 ms |
14204 KB |
Output is correct |
5 |
Correct |
244 ms |
14212 KB |
Output is correct |
6 |
Correct |
284 ms |
14184 KB |
Output is correct |
7 |
Correct |
230 ms |
14172 KB |
Output is correct |
8 |
Correct |
236 ms |
14196 KB |
Output is correct |
9 |
Correct |
231 ms |
12928 KB |
Output is correct |
10 |
Correct |
144 ms |
6960 KB |
Output is correct |
11 |
Correct |
159 ms |
10520 KB |
Output is correct |
12 |
Correct |
98 ms |
2296 KB |
Output is correct |
13 |
Correct |
95 ms |
2300 KB |
Output is correct |
14 |
Correct |
97 ms |
2272 KB |
Output is correct |