#include <iostream>
using namespace std;
int main()
{
int n, s, a, b;
int x[5005] = {};
int y[5005] = {};
int v[5005];
for (int i = 0; i < 5005; i++)
{
v[i] = 1;
}
int minn = 1e9;
int p;
int ans = 0;
cin >> n >> s;
cin >> a >> b;
for (int i = 0; i < n; i++)
{
cin >> x[i] >> y[i];
}
for (int i = 0; i <n; i++)
{
for (int j = 0; j <n; j++)
{
if (y[j]<minn &&v[j]==1&& (a+b)>=x[j])
{
minn = y[j];
p = j;
}
}
if (s<minn)
{
break;
}
s -= minn;
ans++;
minn = 1e9;
v[p] = 0;
}
cout << ans;
}
洛谷P1478 陶陶摘苹果(升级版)---枚举法
最新推荐文章于 2024-02-20 20:44:06 发布