大帽子鱼 @ 2020-11-03 21:44:52
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,s,a,b,cnt;
int x[5005];
int y[5005];
int v[5005]={0};
cin>>n>>s>>a>>b;
for(int i=1;i<=n;i++){
cin>>x[i]>>y[i];
}
for(int i=1;i<=n;i++){
int minn=1e9;
int p;
for(int j=1;j<=n;j++){
if(x[j] <= a+b && v[j] == 0 && y[j] < minn){
minn=y[j];
p=j;
}
}
v[p]=1;
if(s>=minn){
s-=minn;
cnt++;
}
else{
cout<<cnt;
return 0;
}
}
return 0;
}
谁来帮我看看哪里错了,谢谢!
by liuzimingc @ 2021-01-01 15:59:12
@大帽子鱼
by liuzimingc @ 2021-01-01 16:01:42
。。。已经过了,当我没说