Submission #861925

#TimeUsernameProblemLanguageResultExecution timeMemory
861925AiperiiiZalmoxis (BOI18_zalmoxis)C++14
0 / 100
118 ms6484 KiB
#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<<" "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...