这种事情绝对很奇怪的啊
查看原帖
这种事情绝对很奇怪的啊
1175242
Zxx20120715楼主2024/11/23 17:32
#include<bits/stdc++.h>
using namespace std;
int n,s,a,b;
struct node{
	int x,y;
}apple[5010];
int ans=0;
bool cmp(node i,node j){
	return i.y<j.y;
}
int main(){
	cin>>n>>s;
	for(int i=0;i<=n;i++){
		cin>>apple[i].x>>apple[i].y;
	}
	sort(apple+1,apple+n,cmp);
	for(int i=0;i<=n;i++){
		if(a+b>=apple[i].x&&s>=apple[i].y){
			ans++;
			s-=apple[i].x;
		}
		if(s<0) break;
	}
	cout<<ans<<endl;
	return 0;
}

就很蒙,零蛋(紫叶衬红花)求调。

2024/11/23 17:32
加载中...