题解
2025-08-04 10:56:34
发布于:上海
5阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
struct node{
int hp;
int jyz;
}a[10086];
bool manba(node aa,node bb){
if(aa.hp!=bb.hp) return aa.hp<bb.hp;
else return aa.jyz>bb.jyz;
}
int main(){
int t,s,n;
bool man=0;
cin>>t;
for(int i=0;i<t;i++){
cin>>s>>n;
for(int j=0;j<n;j++){
cin>>a[j].hp>>a[j].jyz;
}
sort(a,a+n,manba);
for(int j=0;j<n;j++){
if(s>a[j].hp) s+=a[j].jyz;
else{
cout<<"NO";
man=1;
break;
}
}
if(man==0) cout<<"YES";
cout<<endl;
man=0;
}
return 0;
}
这里空空如也
有帮助,赞一个