Jeff_赵 @ 2022-08-15 10:00:25
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
struct T{ double x,y; }t[N];
bool cmp(int a, int b){
return t[a].y<t[b].y;
}
int main(){
double n,s,a,b,ans=0;
cin>>n>>s>>a>>b;
for(int i=1; i<=n; i++)
{
cin>>t[i].x>>t[i].y;
}
sort(t+1, t+1+(int)n);//懒癌
for(int i=1; i<=n; i++){
if(t[i].x <= a+b && t[i].y<=s){
s-=t[i].y; ans++;
}
}
cout<<ans<<endl;
return 0;
}
by Hisaishi_Kanade @ 2022-08-15 10:01:02
感情问你重载运算符了吗
by Hisaishi_Kanade @ 2022-08-15 10:01:19
你cmp是吃白饭的吗
by 大眼仔Happy @ 2022-08-15 10:02:14
应该写
bool cmp(T a,T b)
{
return a.y<b.y;
}
by Jeff_赵 @ 2022-08-17 10:46:56
dalao我才初中好吧?
by fortyyearslater @ 2022-09-22 21:15:29
@Jeff_赵 洛谷基本都是初中或者高中生吧
by qingranshimanfen @ 2022-10-24 22:53:30
蒟蒻不懂就问:为啥是double?@Jeff_赵
by TemporaryName @ 2022-11-06 11:30:05
@Jeff_赵
sort 调用的格式:sort(a, a+n, cmp)