#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
int n, k;
vector<pair<int, int> > ans;
multiset<int> st;
void f(int x, int depth){
// cout << x << ' ' << depth << '\n';
if(x < 0) assert(false);
if(depth > 10) assert(false);
int mn = (st.empty() ? INT_MAX : *st.begin());
if(x > mn){
f(x-1, depth + 1);
f(x-1, depth + 1);
}else{
ans.push_back({x, depth});
if(st.count(x))
st.erase(st.find(x));
}
}
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
for(int i = 0;i < n; i++){
int x; cin >> x;
st.insert(x);
}
f(30, 0);
if(ans.size() != (n + k)){
assert(false);
}else{
sort(all(ans), [&](pair<int, int> A, pair<int, int> B){
return A.ss < B.ss;
});
for(auto [x, y] : ans) cout << x << ' ';
}
return 0;
}
Compilation message
zalmoxis.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
27 | main(){
| ^~~~
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:36:16: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if(ans.size() != (n + k)){
| ~~~~~~~~~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
210 ms |
95860 KB |
Execution killed with signal 6 |
2 |
Runtime error |
222 ms |
95828 KB |
Execution killed with signal 6 |
3 |
Runtime error |
224 ms |
95816 KB |
Execution killed with signal 6 |
4 |
Runtime error |
221 ms |
95828 KB |
Execution killed with signal 6 |
5 |
Runtime error |
214 ms |
95824 KB |
Execution killed with signal 6 |
6 |
Runtime error |
220 ms |
95964 KB |
Execution killed with signal 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
214 ms |
95828 KB |
Execution killed with signal 6 |
2 |
Runtime error |
213 ms |
95568 KB |
Execution killed with signal 6 |
3 |
Runtime error |
214 ms |
95628 KB |
Execution killed with signal 6 |
4 |
Runtime error |
214 ms |
95604 KB |
Execution killed with signal 6 |
5 |
Runtime error |
220 ms |
95952 KB |
Execution killed with signal 6 |
6 |
Runtime error |
211 ms |
95828 KB |
Execution killed with signal 6 |
7 |
Runtime error |
217 ms |
95800 KB |
Execution killed with signal 6 |
8 |
Runtime error |
225 ms |
95868 KB |
Execution killed with signal 6 |
9 |
Runtime error |
174 ms |
76640 KB |
Execution killed with signal 6 |
10 |
Runtime error |
63 ms |
29024 KB |
Execution killed with signal 6 |
11 |
Runtime error |
105 ms |
48028 KB |
Execution killed with signal 6 |
12 |
Runtime error |
1 ms |
616 KB |
Execution killed with signal 6 |
13 |
Runtime error |
1 ms |
616 KB |
Execution killed with signal 6 |
14 |
Runtime error |
1 ms |
616 KB |
Execution killed with signal 6 |