Universal Cup Judging System

Universal Cup

Límite de tiempo: 6 s Límite de memoria: 512 MB Puntuación total: 100
Estadísticas

你还有 $t$ 分钟就要参加一门非常重要的考试。这门学科有 $n$ 个不同的知识点,编号从 $1$ 到 $n$。学习第 $i$ 个知识点需要 $a_i$ 分钟。

然而,这门学科相当复杂,即使你学习了某个知识点,也不一定能在考试中掌握它。你知道,要对第 $i$ 个知识点有把握,你需要总共学习至少 $b_i$ 个知识点(包括第 $i$ 个知识点本身)。

学习时,在不同知识点之间切换不需要时间。因此,如果你学习了若干个不同的知识点 $p_1, p_2, \dots, p_k$,且满足 $a_{p_1} + a_{p_2} + \dots + a_{p_k} \le t$,那么你就有足够的时间完成学习。如果你学习的知识点总数 $k \ge b_{p_i}$,那么你在考试中就能对知识点 $p_i$ 有把握。注意,学习知识点的顺序并不重要。

你希望确定在考试前应该学习哪些知识点,以最大化你能有把握的知识点数量。

输入格式

每个测试点包含多个测试用例。第一行包含测试用例的数量 $q$ ($1 \le q \le 10^4$)。

接下来是各测试用例的描述。

每个测试用例的第一行包含两个整数 $n$ 和 $t$,分别表示知识点的数量和距离考试剩余的时间 ($1 \le n \le 2 \cdot 10^5$; $1 \le t \le 2 \cdot 10^{14}$)。

接下来的 $n$ 行中,第 $i$ 行包含两个整数 $a_i$ 和 $b_i$,分别表示学习第 $i$ 个知识点所需的时间以及要对第 $i$ 个知识点有把握所需学习的知识点总数 ($1 \le a_i \le 10^9$; $1 \le b_i \le n$)。

保证所有测试用例中 $n$ 的总和不超过 $2 \cdot 10^5$。

输出格式

对于每个测试用例,输出你能有把握的知识点的最大数量。

然后输出 $k$,表示你应该学习的知识点数量,随后输出 $k$ 个不同的整数 $p_1, p_2, \dots, p_k$(顺序不限),表示你应该学习的知识点编号 ($0 \le k \le n$; $1 \le p_i \le n$)。

如果存在多种方案,输出其中任意一种即可。

样例

输入 1

2
4 100
20 1
40 4
60 3
30 3
1 5
10 1

输出 1

2
3
1 2 4
0
0

说明

在第一个测试用例中,你应该学习知识点 1、2 和 4。这总共需要 $20 + 40 + 30 = 90$ 分钟,这在你有 100 分钟的情况下是可行的。虽然你对知识点 2 没有把握(因为你需要学习全部四个知识点才能对它有把握),但你对知识点 1 和 4 有把握。在这个测试用例中,不可能对超过两个知识点有把握。

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.