#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
int n, k, cur;
vector<pair<int, int> > ans;
vector<int> a, all;
void f(int x){
if(x < 0) return;
if(cur >= n or a[cur] >= x){
if(cur < n && a[cur] == x){
ans.push_back({x, 0});
cur++;
}else{
ans.push_back({x, 1});
}
}else{
f(x-1);
f(x-1);
}
}
void split(int x){
if(!k && !x){
all.push_back(x);
}else{
k--;
split(x-1);
split(x-1);
}
}
main(){
cin >> n >> k;
a.resize(n);
for(int i = 0;i < n; i++)cin >> a[i];
f(30);
k = k - (int)ans.size() + n;
for(auto [x, y] : ans){
if(!y){
all.push_back(x);
continue;
}
split(x);
}
for(int x : all) cout << x << ' ';
return 0;
}
Compilation message
zalmoxis.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
35 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
271 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Runtime error |
263 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Runtime error |
271 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Runtime error |
274 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Runtime error |
261 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
259 ms |
262144 KB |
Execution killed with signal 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
264 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Runtime error |
260 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Runtime error |
261 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Runtime error |
262 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Runtime error |
260 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Runtime error |
264 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Runtime error |
255 ms |
262144 KB |
Execution killed with signal 9 |
8 |
Runtime error |
259 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
239 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
185 ms |
262144 KB |
Execution killed with signal 9 |
11 |
Runtime error |
205 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Runtime error |
143 ms |
262144 KB |
Execution killed with signal 9 |
13 |
Runtime error |
143 ms |
262144 KB |
Execution killed with signal 9 |
14 |
Runtime error |
144 ms |
262144 KB |
Execution killed with signal 9 |