Submission #861870

#TimeUsernameProblemLanguageResultExecution timeMemory
861870AiperiiiZalmoxis (BOI18_zalmoxis)C++17
0 / 100
170 ms8456 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; 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); cout<<val<<" "; for(int i=0;i<n;i++){ cout<<a[i]<<" "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...