请求加强数据
查看原帖
请求加强数据
249294
七色丶人偶使楼主2020/11/11 15:44

这没带这撤销的假代码(虽然是我写的)都能过。

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;
}

2020/11/11 15:44
加载中...