QOJ.ac

QOJ

Limite de temps : 8 s Limite de mémoire : 128 MB Points totaux : 100

#4444. 满星坠落

Statistiques

Fall 喜欢玩游戏并收集游戏中各种奇怪的成就。如果他没有以满星通关某个关卡,他会感到不舒服。

今天,Fall 正在玩一款新游戏。该游戏包含 $n$ 个关卡,没有顺序限制,这意味着你可以以任何顺序挑战这些关卡。然而,每个关卡只能挑战一次。在挑战过程中,Fall 可能会受伤或获得稀有物品。假设在挑战第 $i$ 个关卡之前,他的力量值为 $x$,那么在挑战该关卡后,他的力量值将增加 $d_i$。此后,如果他的力量值大于或等于 $s_i$,他就能在该关卡获得满星。

初始时,Fall 的力量值为 $s_0$,他希望找到一种挑战顺序,使得他能获得的满星关卡数量尽可能多。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 20$),表示测试用例的数量。每个测试用例: 第一行包含两个整数 $n, s_0$ ($1 \le n \le 1 \times 10^5, \sum n \le 10^6, |s_0| \le 10^{14}$)。 接下来的 $n$ 行,第 $i$ 行包含两个整数 $d_i, s_i$ ($|d_i| \le 10^9, |s_i| \le 10^{14}$),表示第 $i$ 个关卡的信息。

输出格式

对于每个测试用例,输出一行,包含一个整数,表示 Fall 最多能获得的满星关卡数量。

样例

样例输入 1

1
3 0
4 5
2 5
1 100

样例输出 1

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.