made_in_Nanxun @ 2023-12-05 13:51:12
我是蒟蒻,本题自己写了一段代码,可报错信息太过离谱,附上代码,求大佬解答为什么报错
#include<bits/stdc++.h>
using namespace std;
struct apple{
int x,y;
}p[5010];
bool cmp(apple w,apple v){
return w.y<v.y;
}
int main()
{
int n,s,a,b,sum=0;
cin>>n>>s>>a>>b;
for(int i=1; i<=n; i++){
cin>>p[i].x>>p[i].y;
}
sort(a+1, a+n+1, cmp);
for(int i=1; i<=n; i++){
if(s-p[i].y<0) break;
if(p[i].x<a+b){
s-=p[i].y;
sum++;
}
}
cout<<sum;
}
by MYiFR @ 2023-12-05 13:57:47
by MYiFR @ 2023-12-05 13:58:55
你本来想写