AnOIer @ 2023-10-21 20:34:13
#include<bits/stdc++.h>
using namespace std;
struct apple{//结构体
int h;
int s;
}a[1000000];
bool cmp(apple x,apple y){
if(x.s==y.s) return x.h<y.h;
return x.h>y.h;
}//以使用的力气排序
int main(){
int n,s,h,ha,ans=0;
cin>>n>>s;
cin>>h>>ha;
for(int i=1;i<=n;i++){
cin>>a[i].h>>a[i].s;
}
sort(a+1,a+1+n,cmp);
//for(int i=1;i<=n;i++) cout<<a[i].h<<" "<<a[i].s<<endl;
int sh=h+ha;
for(int i=1;i<=n;i++){
if(sh>=a[i].h&&s>=a[i].s){
s-=a[i].s;
ans++;
}
}
cout<<ans;
return 0;
}
by Star_F @ 2023-10-21 20:59:17
开个 long long
试试?
@battlefield5
by AnOIer @ 2023-10-21 21:01:10
@Star_F 我逝逝
by Star_F @ 2023-10-21 21:02:30
不行的话建议 ctj
by AnOIer @ 2023-10-21 21:03:04
@Star_F 不行啊,数据并不大,开了没什么用
by AnOIer @ 2023-10-21 21:03:36
@Star_F 6