繁华模拟赛 ljw搭积木
#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; const int maxn = 6005; int n,x[maxn]; int cmd,cnt,ans,max_x; int main(){ freopen("box.in","r",stdin); freopen("box.out","w",stdout); ios::sync_with_stdio(false); cin>>n; for(int i = 1;i <= n;i++){ cin>>cmd; x[cmd]++; max_x = max(max_x,cmd); } while(1){ cnt = 0; for(int i = 0;i <= max_x;i++){ while(x[i] && i >= cnt){ x[i]--; cnt++; } } if(!cnt) break; ans += 1; } cout<<ans; return 0; }