Xlon_Rainfi @ 2024-01-13 21:44:42
需要特判
by Mark_Zhu @ 2024-02-02 11:33:54
@wuxinlong 我都不用啊
#include<bits/stdc++.h>
using namespace std;
struct node{
int l,h;
bool operator <(node b){
return l<b.l;
}
}apple[5005];
int main(){
int n,s,a,b,ans=0;
cin>>n>>s>>a>>b;
for(int i=1;i<=n;i++)cin>>apple[i].h>>apple[i].l;
sort(apple+1,apple+n+1);
for(int i=1;i<=n;i++)if(apple[i].h<a+b and apple[i].l<=s){s-=apple[i].l;ans++;}
cout<<ans;
return 0;
}
我这不是AC了吗?