NULL11 @ 2022-01-01 20:27:51
#include<bits/stdc++.h>
using namespace std;
int n,s,a,b,sum=0,x[300],y[110];
int main(){
scanf("%d %d",&n,&s);
scanf("%d %d",&a,&b);
for(int i=1;i<=n;i++) scanf("%d %d",&x[i],&y[i]);
sort(y+1,y+n+1);
for(int i=1;i<=n;i++)
{
if(a+b>=x[i]&&s>=y[i])
{
sum++;
s-=y[i];
}
}
printf("%d",sum);
return 0;
}
by ud2_ @ 2022-01-01 20:29:11
y
排序了,x
呢?
by xhz_ @ 2022-01-01 20:36:29
@NULL11 写个struct,对struct进行排序不就行了。
by xhz_ @ 2022-01-01 20:37:56
你这排序后,