zust_lms @ 2020-02-15 22:07:11
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
struct node{
int x;
int y;
}u[5010];
bool cmp(node a,node b)
{
return a.y<b.y;
}
int main()
{
int n,s,a,b,idx=0,sum=0,k;
cin >> n >> s >> a >> b;
while(n--)
{
int x,y;
cin >> x >> y;
if(x<=a+b)
{
u[idx].x=x;
u[idx].y=y;
idx++;
}
}
sort(u,u+idx,cmp);
for(int i=0;i<idx;i++)
{
sum+=u[i].y;
if(sum<=s)
{
k++;
}
}
cout << k << endl;
return 0;
}
蟹蟹各位啦
by Islauso @ 2020-02-15 22:11:01
恕我直言,你在逗我吗,难道不判断一下当前苹果摘不摘得到吗?
by zust_lms @ 2020-02-17 17:06:23
@xiaolin_ emmm,我存进结构体的时候那个判断可以吗。。
by Islauso @ 2020-02-17 17:57:44
@zust_lms emmmm……对不起,我眼瞎了(罚自己扇自己嘴巴300下