Mono_pigsicklie @ 2019-03-20 14:00:49
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main() {
int n,s,a,b,i,j;//n,num s,liqi a,yizi b,zuida
int xi[5010],yi[5010];
memset(xi,0,sizeof(xi));
memset(yi,0,sizeof(yi));
scanf("%d%d%d%d",&n,&s,&a,&b);
int maxn=a+b;
for(i=1; i<=n; i++)
cin>>xi[i]>>yi[i];
int total=0;
for(i=1; i<=n; i++) {
for(j=1; j<=n; j++) {
if(yi[i]>yi[i+1]) {
swap(xi[i],xi[i+1]);
swap(yi[i],yi[i+1]);
}
}
}
for(i=1; i<=n; i++) {
if(maxn>=xi[i]&&s>=yi[i]) {
s-=yi[i];
total++;
continue;
}
if(s<yi[i]) {
break;
}
}
cout<<total;
return 0;
}
by 幻影学霸刘 @ 2019-03-25 18:58:45