Codeforces 230A - Dragons Solution

 Solution in C++: 

///******Bismillahir-Rahmanir-Rahim******///

///AH Tonmoy

///Department of CSE,23rd batch

///Islamic University,Bangladesh 

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,s,i,f=0;
  6. pair<int,int>p[1009];
  7. cin>>s>>n;
  8. int x[n+9],y[n+9];
  9. for(i=0; i<n; i++)
  10. {
  11. cin>>p[i].first>>p[i].second;
  12. }
  13. sort(p,p+n);
  14. for(i=0; i<n; i++)
  15. {
  16. if(p[i].first<s)
  17. s=s+p[i].second;
  18. else
  19. {
  20. cout<<"NO"<<endl;
  21. return 0;
  22. }
  23. }
  24. cout<<"YES"<<endl;
  25. }

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.