Yikara @ 2021-05-09 10:12:40
#include<bits/stdc++.h>
using namespace std;
int x[5005],y[5005],z[5005];
int main(){
int n,s,a,b,point=0,count=0;
cin>>n>>s>>a>>b;
for(int i=0;i<n;i++){
cin>>x[i]>>y[i];
}
for(int i=0;i<n;i++){
if(x[i]<=a+b){
z[point]=y[i];
point++;
}
}
sort(z,z+point);
for(int i=0;1;i++){
if(s<z[i]){
break;
}
else{
s-=z[i];
count++;
}
}
cout<<count;
return 0;
}
思路是先筛除摘不到的,再把剩下的按所需的体力排序,最后累加到不能再摘为止
by Yikara @ 2021-05-09 10:16:25
我晕,刚刚下载数据看了看,我似乎被埋伏了......
by Aslf_Ek @ 2021-07-26 23:08:39
好家伙,同道中人