yanghanchen @ 2022-11-30 13:58:37
#include<bits/stdc++.h>
using namespace std;
struct apple{
int high,liqi;
}A[5100];
bool cmp(apple a,apple b)
{
return a.liqi<=b.liqi;
}
int main()
{
int n,s,a,b,x,y,q=0;
scanf("%d%d%d%d",&n,&s,&a,&b);
for(int i=0;i<n;i++)
{
scanf("%d%d",&x,&y);
if(x<=a+b)
{
A[q].high=x;
A[q].liqi=y;
q++;
}
}
sort(A,A+q,cmp);
int ans=0;
for(int i=0;i<q;i++)
{
s-=A[i].liqi;
if(s<0)
{
break;
}
ans++;
}
cout<<ans;
}
by Lucky_Cloud @ 2022-11-30 14:41:25
虽然我也不知道为什么,但它是真的神奇;只需把
bool cmp(apple a,apple b)
{
return a.liqi<=b.liqi;
}
改成:
bool cmp(apple a,apple b)
{
return a.liqi<b.liqi;
}
是不是很神奇 AC现场
by BIOS @ 2022-12-25 15:44:50
@omgdlc 天啊,我也是这么RE的,改了一个符号就AC了