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

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.