yxj725 @ 2024-09-17 16:25:34
#include<bits/stdc++.h>
using namespace std;
struct node {
int x,y;
};
node a[5010];
bool cmp (node m,node v) {
return m.y<m.y;
}
int main (){
int n,s,p,b;
cin>>n>>s>>p>>b;
for (int i=1;i<=n;i++) {
cin>>a[i].x>>a[i].y;
}
sort(a+1,a+n+1,cmp);
int ans=0;
for (int i=i;i<=n;i++) {
if (a[i].x<=p+b&&s-a[i].y>=0) {
ans++;
s-=a[i].y;
}
}
cout<<ans<<endl;
return 0;
}
by sg1998 @ 2024-09-17 21:10:56
第8行m.y<v.y 第18行int i=1 你太急了