Codeforces 230A - Dragons Solution
Solution in C++:
///******Bismillahir-Rahmanir-Rahim******///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,s,i,f=0;
- pair<int,int>p[1009];
- cin>>s>>n;
- int x[n+9],y[n+9];
- for(i=0; i<n; i++)
- {
- cin>>p[i].first>>p[i].second;
- }
- sort(p,p+n);
- for(i=0; i<n; i++)
- {
- if(p[i].first<s)
- s=s+p[i].second;
- else
- {
- cout<<"NO"<<endl;
- return 0;
- }
- }
- cout<<"YES"<<endl;
- }
No comments