QWQ_jyc @ 2023-07-03 22:35:28
#include <bits/stdc++.h>
using namespace std;
long long n,s,zg,yg,tg,m,g;
struct qwe{
int x,y,z;
}a[114514];
int cmp(qwe x,qwe y){
return x.y<y.y;
}
int main(){
cin>>n>>s>>yg>>tg;
zg=yg+tg;
for(int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
for(int i=1;i<=n;i++){
if(a[i].x>zg) a[i].z=1;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++){
if(m<s&&a[i].z!=1){
g++;
m+=a[i].y;
}
}
cout<<g;
return 0;
}
by popo0815 @ 2023-07-04 07:05:29
题目是在s<0 前能摘苹果数,应该是m+a[i].y<=s;