이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
zalmoxis.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
35 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |