Codeforces 1165 B. Polycarp Training solution

Solve in C++:

///**********ALLAH IS ALMIGHTY************///
     ///AH Tonmoy
    ///Department of CSE,23rd batch
    ///Islamic University,Bangladesh
  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4. int main()
  5. {
  6. int n,i,a[200900],c=0;
  7. cin>>n;
  8. for(i=0; i<n; i++)
  9. {
  10. cin>>a[i];
  11. }
  12. sort(a,a+n);
  13. for (i=0;i<n;i++)
  14. {
  15. if(a[i]>c)
  16. {
  17. c++;
  18. }
  19. }
  20. cout<<c<<endl;
  21. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.