EmadMoh178

Untitled

Sep 14th, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. int main()
  2. {
  3.     long long s,n;
  4.     pair<int,int>m[n];
  5.    
  6.     cin>>s>>n;
  7.    
  8.     for(int i=0;i<n;i++)
  9.         cin>>m[i].first>>m[i].second;
  10.    
  11.     sort(m,m+n);
  12.    
  13.     for(auto &m : m){
  14.         if(s>m.first)s+=m.second;
  15.         else {
  16.             cout<<"NO";
  17.             return 0;
  18.         }
  19.     }
  20.    
  21.     cout<<"YES";
  22.    
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment