fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. int main() {
  8. int n, x[105], pl=0, cnt=0, b[105]={0};
  9. vector <int> v;
  10. scanf("%d", &n);
  11. for(int i=0; i<n; i++) scanf("%d", &x[i]);
  12. sort(x, x+n);
  13. while(cnt<n) {
  14. pl++;
  15. for(int i=0; i<n; i++) if(x[i]>=v.size() && b[i]==0) v.push_back(x[i]), b[i]=1, cnt++;
  16. v.clear();
  17. }
  18. printf("%d", pl);
  19. return 0;
  20. }
Success #stdin #stdout 0s 3436KB
stdin
9
0 1 1 0 2 0 3 45 4
stdout
3