IamSB_005 @ 2023-09-17 19:57:56
##include<bits/stdc++.h>
using namespace std;
int n,s;
int h,l;
int ans = 0;
struct A{
int a,b;
}g[50010];
bool cmp(A x,A y){
return x.a < x.a;
}
int main(){
cin >> n >> s;
cin >> h >> l;
for(int i = 1;i <= n;i++){
cin >> g[i].a >> g[i].b;
}
sort(g , g + n, cmp);
for(int i = 1;i <= n;i++){
if(g[i].a <= h + l && s >= g[i].b ){
ans++;
s -= g[i].b;
}
}
cout << ans;
return 0;
}
by Demo_B11 @ 2023-09-17 20:02:52
第19行应该是sort(g+1,g+n+1,cmp)吧