#include<bits/stdc++.h>
#define I inline void
using namespace std ;
using ll = long long ;
using ld = long double ;
const int N = 2e6 + 7 ;
// How interesting!
int n , k ;
int a[N] ;
int used = 0 ;
vector<int> ans ;
int dfs(int x , int val){
if(a[x] > val){
ans.push_back(val) ;
used ++ ;
return x ;
}
if(a[x] == val){
ans.push_back(val) ;
return x + 1 ;
}
int ret1 = dfs(x , val - 1) ;
int ret2 = dfs(ret1 , val -1 ) ;
return ret2 ;
}
int main(){
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
//freopen("in.in", "r" , stdin) ;
cin >> n >> k ;
a[n] = (1<<30) ;
for(int i = 0 ;i < n ; i++){
cin >> a[i] ;
}
dfs(0 , 30 ) ;
vector<int> ans2 ;
for(auto u : ans){
ans2.push_back(u) ;
/*while(used < k && ans2.back() > 1){
int x = ans2.back() ;
ans2.pop_back() ;
ans2.push_back(x-1) ;
ans2.push_back(x-1) ;
used ++ ;
}*/
}
reverse(ans2.begin() , ans2.end()) ;
for(auto u : ans){
cout<< u <<" " ;
}
return 0 ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
166 ms |
14312 KB |
Output is correct |
2 |
Correct |
187 ms |
14440 KB |
Output is correct |
3 |
Correct |
172 ms |
14312 KB |
Output is correct |
4 |
Correct |
168 ms |
14440 KB |
Output is correct |
5 |
Correct |
165 ms |
14312 KB |
Output is correct |
6 |
Correct |
173 ms |
14424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
178 ms |
14308 KB |
Unexpected end of file - int32 expected |
2 |
Correct |
169 ms |
14308 KB |
Output is correct |
3 |
Incorrect |
207 ms |
14288 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
168 ms |
14312 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
164 ms |
14312 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
170 ms |
14312 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
170 ms |
14308 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
168 ms |
14312 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
159 ms |
13288 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
68 ms |
6252 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
112 ms |
11112 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
1 ms |
384 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
1 ms |
384 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
1 ms |
384 KB |
Unexpected end of file - int32 expected |