Submission #861931

#TimeUsernameProblemLanguageResultExecution timeMemory
861931AiperiiiZalmoxis (BOI18_zalmoxis)C++14
0 / 100
1046 ms6712 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; void dfs(int v){ bool flag=false; for(int i=0;i<v;i++){ if(cnt[i]!=0){ flag=true; } } if(!flag){ val=v; } 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++){ cout<<a[i]<<" "; } cout<<val<<" "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...