60pts RE#3#5
查看原帖
60pts RE#3#5
1445328
sunqikai0805楼主2025/7/22 19:02
#include<bits/stdc++.h>
//#define ll long long
//#define size (/*num*/)

using namespace std;

int n,a,s,b,cnt;

struct node{
	int x;
	int y;
}ap[5005];

bool cmp(node q,node p){
	if(p.x > a + b) return true;
	if(q.x > a + b) return false;
	return q.y < p.y;
}

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	//freopen("apple.in","r",stdin);
	//freopen("apple.out","w",stdout);
	cin >> n >> s >> a >> b;
	for(int i = 1;i <= n;++i) cin >> ap[i].x >> ap[i].y;
	sort(ap + 1,ap + n + 1,cmp);
	for(int i = 1;i <= n;++i){
		if(s < ap[i].y) break;
		s -= ap[i].y;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

我只想知道我错哪了,不想要代码,回复记得@我一下,谢谢

2025/7/22 19:02
加载中...