圣啦啦 @ 2020-02-11 20:37:47
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
int x;
int y;
}a[5005];
bool cmp(node a,node b){
return a.y<b.y;
}
int main(){
int n,s;
cin>>n>>s;
int c,b;
cin>>c>>b;
int sum=c+b;
for(int i=0;i<n;i++){
cin>>a[i].x>>a[i].y;
}
sort(a,a+n,cmp);
int tot=0;
for(int i=0;i<n;i++){
if(s<0){
break;
}
if(s>=0&&sum>=a[i].x){
tot++;
s-=a[i].y;
}
}
cout<<tot;
return 0;
}
by yangrunze @ 2020-02-12 07:15:59
不用谢qwq