zhuliangkunlikeLC @ 2022-12-19 12:07:06
#include <bits/stdc++.h>
using namespace std;
int n,s,a,b,x2,x21[100000],y2,y21[100000];
long long sum;
long long ii,num;
int main() {
cin>>n>>s>>a>>b;
sum=a+b;
for(int i=0;i<n;i++){
cin>>x2>>y2;
if(x2<=sum){
x21[ii]=x2;
y21[ii]=y2;
ii++;
}
}
sort(y21,y21+ii);
int i=0;
while(s>0&&s-y21[i+1]>=0){
s-=y21[i];
i++;
num++;
}
cout<<num;
return 0;
}
by SmileMask @ 2022-12-19 13:16:48
@zhuliangkunlikeLC
把这里
while(s>0&&s-y21[i+1]>=0){
s-=y21[i];
i++;
num++;
}
改成
while(s>0&&s-y21[i]>=0){
s-=y21[i];
i++;
num++;
}
就行了
by zhuliangkunlikeLC @ 2022-12-19 14:56:37
@ikun_zhs 谢谢
by deity_of_legend @ 2023-01-06 17:58:20
这都不会