taoyunpeng @ 2022-05-09 13:30:06
#include <iostream>
#include <algorithm>
using namespace std;
struct lqacn
{
int x;
int y;
}k[5005];
bool slk(lqacn a, lqacn b)
{
return a.y < b.y;
}
int main()
{
int n, s, t, g;
cin >> n >> s >> t >> g;
int h = t + g;
for (int i = 1; i <= n; i++)
{
cin >> k[i].x >> k[i].y;
}
sort(k + 1, k + n + 1, slk);
int ans = 0;
for (int i = 1; i <= n; i++)
{
if(s > k[i].y && h > k[i].x) ans++;
}
cout << ans;
return 0;
}
by Orange1015 @ 2022-05-13 18:11:13
你的s没消耗,加一个 s-=k[i].y 就行了。