这没带这撤销的假代码(虽然是我写的)都能过。
hack:
in:
2 26
10 10
15 1
out:
2
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll MAXN = 1e6+10;
ll N, M, ans;
pll t[MAXN];
priority_queue <pll, vector <pll>, greater<pll> > q;
int main() {
scanf("%lld%lld", &N, &M);
for (ll i = 1; i <= N; i++)
scanf("%lld%lld", &t[i].first, &t[i].second);
for (ll i = 1; i <= N; i++)
q.push(make_pair(t[i].first + t[i].second, t[i].first));
ll where = 0, now = 0;
while (!q.empty()) {
now += q.top().first - q.top().second;
now += abs(q.top().second - where);
where = q.top().second;
q.pop();
if (now <= M) ans++;
else break;
}
printf("%lld\n", ans);
return 0;
}