shuren @ 2020-12-24 14:13:58
#include<bits/stdc++.h>
using namespace std;
struct ll{
int o,p;
}x[10000];
bool cmp(ll a,ll b)
{
if(a.p>b.p) return 0;
else return 1;
}
int main()
{
long long n,s,a,b,num=0;
cin>>n>>s>>a>>b;
for(long long i=0;i<n;i++)
cin>>x[i].o>>x[i].p;
sort(x,x+n,cmp);
for(int i=0;i<n;i++)
{
if((a+b)>=x[i].o)
{
if(x[i].p<=s)
{
s-=x[i].p;
num++;
}
} if(x[i].p>s) {
break;
}
}
cout<<num;
return 0;
}
by expect @ 2020-12-24 18:21:58
cmp那个>改成>=
by BEAUT @ 2022-08-05 10:34:41
@expect 弱弱问一句,why? 谢谢
by expect @ 2022-08-05 17:04:26
@WHYJZR sort传进去的cmp要求cmp(x,x)=false,要不然会RE