调不出来
查看原帖
调不出来
218180
lighthouse楼主2021/7/9 15:53
#include <bits/stdc++.h>

using namespace std;

struct apple{
	int x, y;
}ap[5100];

bool cmp(apple x, apple y){
	return x.y <= y.y;
}

int main(){
	int n, s, a, b;
	scanf("%d%d%d%d", &n, &s, &a, &b);
	int ans = 0;
	for(int i = 0;i < n;i++){
		scanf("%d%d", &ap[i].x, &ap[i].y);
	}
	sort(ap, ap + n, cmp);
	for(int i = 0;i < n;i++){
		if(ap[i].x > (a + b)) continue;
		if(s < ap[i].y) break;
		s -= ap[i].y;
		ans++;
	}
	cout << ans;
	return 0;
}

第三个点和第五个点RE,求助

2021/7/9 15:53
加载中...