求助!!只过了4个点
查看原帖
求助!!只过了4个点
519573
Daniel_yao楼主2022/2/19 17:15
#include<bits/stdc++.h>
using namespace std;

struct node{
	int x, y;
}a[5005];

int n, s, c, b, ans;

bool cmp(node x, node y){
	if(x.y != y.y){
		return x.y < y.y;
	}
	return x.x < y.x;
} 

int main(){
	cin >> n >> s >> c >> b;
	for(int i = 1;i <= n;i++){
		cin >> a[i].x >> a[i].y;
	}
	sort(a+1, a+n+1, cmp); 
	c += b;
	for(int i = 1;i <= n;i++){
		if(c >= a[i].x && s - a[i].y > 0){
			s -= a[i].y;
			ans++; 
		}
	}
	cout << ans;
	return 0;
} 

2022/2/19 17:15
加载中...