#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;
vector <int> res;
void dfs(int v){
bool flag=false;
for(int i=0;i<v;i++){
if(cnt[i]!=0){
flag=true;
}
}
if(!flag){
val=v;
res.push_back(v);
return;
}
else{
if(cnt[v-1]==1){
res.push_back(v-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){
res.push_back(v-1);
res.push_back(v-1);
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(auto i : res)cout<<i<<" ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
110 ms |
6484 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
106 ms |
6232 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
105 ms |
6236 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
105 ms |
6364 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
105 ms |
6256 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
106 ms |
6108 KB |
Unexpected end of file - int32 expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
105 ms |
6236 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
118 ms |
6384 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
113 ms |
6236 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
105 ms |
6252 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
110 ms |
6224 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
107 ms |
6228 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
106 ms |
6224 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
109 ms |
6364 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
84 ms |
5092 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
32 ms |
2112 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
54 ms |
3156 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
0 ms |
344 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 |