0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-12 03:46:29 +00:00
OI-codes/S2OJ/1603/data/std.cpp

38 lines
652 B (Stored with Git LFS)
C++

#include<bits/stdc++.h>
#define L long long
#define M 100005
using namespace std;
struct node{
int a,b;
friend bool operator <(node A,node B){
bool typeA=(A.a<A.b);
bool typeB=(B.a<B.b);
if(typeA!=typeB) return typeA>typeB;
if(typeA) return A.a<B.a;
return A.b>B.b;
}
void rd(){scanf("%d%d",&a,&b);}
}p[M];
int Main(){
L n,k;
cin>>n>>k;
for(int i=1;i<=n;i++) p[i].rd();
sort(p+1,p+n+1);
for(int i=1;i<=n;i++){
k-=p[i].a;
if(k<1) {printf("NO\n"); return 0;}
k+=p[i].b;
}
printf("YES\n");
return 0;
}
int main(){
// freopen("tower.in","r",stdin);
// freopen("tower.out","w",stdout);
int T; cin>>T;
while(T--) Main();
}