czj2006 @ 2019-10-04 22:08:32
#include<iostream>
#include<algorithm>
using namespace std;
int n,s,a,b,ans;
struct data {
int x,y;
}t[5001];
bool cmp (data p,data q) {
return p.y<q.y;
}
int main(){
cin>>n>>s>>a>>b;
for (int i=1;i<=n;i++) {
cin>>t[i].x>>t[i].y;
}
sort(t+1,t+n+1,cmp);
for (int i=1;i<=n;i++) {
if (a+b>=t[i].x && s-t[i].y>0) {
s-=t[i].y;
ans++;
}
else break;
}
cout<<ans<<endl;
return 0;
}
by Konnyaku_ljc @ 2019-10-04 22:16:44
@czj2006 1
s-t[i].y>=0
2 dont break;
by czj2006 @ 2019-10-07 11:26:41
谢谢