fork download
  1. #include <bits/stdc++.h>
  2. #define MOD 1000000007
  3. #define Tran_Hoan_Thien ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
  4. #define fi first
  5. #define se second
  6. #define pb push_back
  7. #define vi vector<int>
  8. #define ll long long
  9. #define vll vector<ll>
  10. #define db double
  11. using namespace std;
  12. int main(){
  13. freopen("CAU3.INP ","r",stdin);
  14. freopen("CAU3.OUT","w",stdout);
  15. Tran_Hoan_Thien;
  16. int n;cin>>n;
  17. vector<int> a(n);
  18. for(int &x:a) cin>>x;
  19. sort(a.begin(),a.end(),greater<int> ());
  20. int dem=1;
  21. int k=a[0];
  22. for(int i=1;i<n;i++){
  23. if(k<=0) break;
  24. dem++;
  25. k=min(k-1,a[i]);
  26. }
  27. cout<<dem;
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty