#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 66;
vector<int> v[N] , a(N);
void func(int x , int k){
if(k == 0 || x == 0){
cout<<x<<" ";
return;
}
k--;
func(x-1 ,k);
func(x-1 ,k);
}
int32_t main()
{
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>a[i];
}
a[n] = 30;
int cem = 0;
for(int i = 0; i < n; i++){
cem += (1<<a[i]);
while(__builtin_ctz(cem) < a[i+1]){
v[i].push_back(__builtin_ctz(cem));
cem += (cem & -cem);
k--;
}
}
for(int i=0;i<n;i++){
cout << a[i] << " ";
for(int x : v[i]){
func(x, k);
}
}
}
/*
1 1 2 2 3 3 4 4
1
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
190 ms |
29816 KB |
Output is correct |
2 |
Correct |
197 ms |
30040 KB |
Output is correct |
3 |
Correct |
178 ms |
29760 KB |
Output is correct |
4 |
Correct |
176 ms |
29876 KB |
Output is correct |
5 |
Correct |
186 ms |
29876 KB |
Output is correct |
6 |
Correct |
184 ms |
29876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
445 ms |
37540 KB |
Expected EOF |
2 |
Correct |
185 ms |
29908 KB |
Output is correct |
3 |
Incorrect |
182 ms |
30032 KB |
Expected EOF |
4 |
Incorrect |
784 ms |
45756 KB |
Expected EOF |
5 |
Incorrect |
286 ms |
32960 KB |
Expected EOF |
6 |
Incorrect |
417 ms |
36432 KB |
Expected EOF |
7 |
Incorrect |
534 ms |
39616 KB |
Expected EOF |
8 |
Incorrect |
233 ms |
31148 KB |
Expected EOF |
9 |
Execution timed out |
1057 ms |
57616 KB |
Time limit exceeded |
10 |
Execution timed out |
1036 ms |
58324 KB |
Time limit exceeded |
11 |
Execution timed out |
1041 ms |
58244 KB |
Time limit exceeded |
12 |
Execution timed out |
1049 ms |
57136 KB |
Time limit exceeded |
13 |
Execution timed out |
1051 ms |
56860 KB |
Time limit exceeded |
14 |
Execution timed out |
1044 ms |
56640 KB |
Time limit exceeded |