Davnaver @ 2024-02-23 11:09:07
#include<iostream>
#include<algorithm>
using namespace std;
struct apple
{
int x,y;
}app[5005];
bool cmp(apple app1,apple app2)
{
return app1.y<=app2.y;
}
int main()
{
int n,s,a,b,ans=0;
cin>>n>>s>>a>>b;
for(int i=1;i<=n;i++)
cin>>app[i].x>>app[i].y;
sort(app+1,app+n+1,cmp);
for(int i=1;i<=n;i++)
{
if(s>=app[i].y)
{
if(app[i].x<=b || app[i].x<=b+a)
{
ans++;
s=s-app[i].y;
if(s<=0)
break;
}
}
}
cout<<ans<<endl;
return 0;
}
by Orz___zrO @ 2024-02-23 11:13:39
@Davnaver cmp≤改成<
by Davnaver @ 2024-02-23 11:20:40
@Orz___zrO 对了谢谢你!!
by chairleo @ 2024-03-27 23:09:14
@Orz___zrO 请问为什么要这么写呢