20分求dalao帮帮蒟蒻
查看原帖
20分求dalao帮帮蒟蒻
671576
felixxiaoniu楼主2024/7/9 14:32
#include <bits/stdc++.h>
using namespace std;
int n, s, a, b, x, y, ans = 0, str[101];

int main() {
	cin >> n >> s >> a >> b;
	int tot = a + b;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		if (x <= tot)
			str[b]++;
	}
	for (int i = 0; i <= 100 && s >= 0; i++) {
		while (str[i]) {
			s = s - i;
			ans++;
			str[i]--;
			if (s < 0) {
				ans--;
				break;
			}
		}
	}
	cout << ans;
	return 0;
}
2024/7/9 14:32
加载中...