你这我有点看不懂
by D23lhc @ 2024-03-17 11:08:08
AC
```cpp
#include <bits/stdc++.h>
using namespace std;
int n,s,a,b,ans;
struct node{
int x;
int y;
}c[10086];
bool cmp(node x1,node x2)
{
return x1.y < x2.y;
}
int main()
{
cin >> n >> s >> a >> b;
for (int i=1;i<=n;i++)
{
cin >> c[i].x >> c[i].y;
}
sort(c+1,c+n+1,cmp);
for (int i=1;i<=n;i++)
{
if (a + b >= c[i].x && s >= c[i].y)
{
ans++;
s = s - c[i].y;
}
}
cout << ans << endl;
return 0;
}
by HEROBRINEH @ 2024-03-17 11:10:23
```
#include <bits/stdc++.h>
using namespace std;
int n,s,a,b,ans;
struct node{
int x;
int y;
}c[10086];
bool cmp(node x1,node x2)
{
return x1.y < x2.y;
}
int main()
{
cin >> n >> s >> a >> b;
for (int i=1;i<=n;i++)
{
cin >> c[i].x >> c[i].y;
}
sort(c+1,c+n+1,cmp);
for (int i=1;i<=n;i++)
{
if (a + b >= c[i].x && s >= c[i].y)
{
ans++;
s = s - c[i].y;
}
}
cout << ans << endl;
return 0;
}
```
by D23lhc @ 2024-03-17 11:12:36
@[HEROBRINEH](/user/1113507)
你这什么思路
by D23lhc @ 2024-03-17 11:13:53
@[HEROBRINEH](/user/1113507)
人家叫你调他的代码,帮他优化,而不是将题解一字不差的复制上来
by D23lhc @ 2024-03-17 11:19:49
@[m3o7o2n1](/user/1279238) 测试点中有0 0
0 0
by 88jnt @ 2024-05-15 13:05:56