#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
int cnt[40];
int val=-1;
void dfs(int v){
bool flag=false;
for(int i=0;i<v;i++){
if(cnt[i]!=0){
flag=true;
}
}
if(!flag){
val=v;
return;
}
if(cnt[v-1]==1){
cnt[v-1]--;
dfs(v-1);
}
else if(cnt[v-1]==0){
dfs(v-1);
dfs(v-1);
}
else if(cnt[v-1]==2){
cnt[v-1]=0;
}
}
signed main(){
int n,k;
cin>>n>>k;
vector <int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
cnt[a[i]]++;
}
dfs(30);
for(int i=0;i<n;i++){
if(a[i]<=val && val!=-1){
cout<<val<<" "<<a[i]<<" ";
val=-1;
}
else{
cout<<a[i]<<" ";
}
}
if(val!=-1){
cout<<val<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
164 ms |
6400 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
169 ms |
6300 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
163 ms |
6384 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
166 ms |
6384 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
164 ms |
6224 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
164 ms |
6388 KB |
Unexpected end of file - int32 expected |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
163 ms |
6384 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
163 ms |
6388 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
195 ms |
6408 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
167 ms |
6484 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
163 ms |
6228 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
170 ms |
6408 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
160 ms |
6396 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
162 ms |
6228 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
131 ms |
5204 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
50 ms |
2128 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
82 ms |
3416 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
0 ms |
600 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - int32 expected |