#include <bits/stdc++.h>
using namespace std;
#define int long long
#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);
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)){
// cout << "WHAT";
// }else{
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(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1050 ms |
47424 KB |
Time limit exceeded |
2 |
Execution timed out |
1041 ms |
47184 KB |
Time limit exceeded |
3 |
Execution timed out |
1042 ms |
47404 KB |
Time limit exceeded |
4 |
Execution timed out |
1037 ms |
47184 KB |
Time limit exceeded |
5 |
Execution timed out |
1016 ms |
47440 KB |
Time limit exceeded |
6 |
Execution timed out |
1029 ms |
47440 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1038 ms |
47400 KB |
Time limit exceeded |
2 |
Execution timed out |
1053 ms |
47700 KB |
Time limit exceeded |
3 |
Execution timed out |
1014 ms |
47304 KB |
Time limit exceeded |
4 |
Execution timed out |
1016 ms |
47440 KB |
Time limit exceeded |
5 |
Execution timed out |
1060 ms |
47396 KB |
Time limit exceeded |
6 |
Execution timed out |
1028 ms |
48676 KB |
Time limit exceeded |
7 |
Execution timed out |
1039 ms |
48472 KB |
Time limit exceeded |
8 |
Execution timed out |
1034 ms |
48464 KB |
Time limit exceeded |
9 |
Execution timed out |
1068 ms |
39036 KB |
Time limit exceeded |
10 |
Execution timed out |
1049 ms |
15304 KB |
Time limit exceeded |
11 |
Execution timed out |
1026 ms |
24916 KB |
Time limit exceeded |
12 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
1 ms |
348 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - int32 expected |