Tommyshizichen @ 2024-01-31 17:01:41
#include<bits/stdc++.h>
using namespace std;
struct da{
int a,b;
}aa[50005];
bool cmp(da a1,da b1)
{
if(a1.b>b1.b)
{
return 0;
}
return 1;
}
int main()
{
int n,s,h1,h2;
cin>>n>>s>>h1>>h2;
int h=h1+h2;
for(int i=1;i<=n;i++)
{
cin>>aa[i].a>>aa[i].b;
}
sort(aa+1,aa+1+n,cmp);
int ans=0;
for(int i=1;i<=n;i++)
{
if(h>=aa[i].a)
{
if(s-aa[i].b>=0)
{
s-=aa[i].b;
ans++;
}
}
}
cout<<ans;
return 0;
}
by Kazemaru @ 2024-01-31 17:19:06
一眼丁真,鉴定为 cmp 定义成小于等于了
by Tommyshizichen @ 2024-02-01 08:46:49
@Kazemaru 感谢