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 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

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

Powered by Blogger.