QOJ.ac

QOJ

Limite de temps : 4 s Limite de mémoire : 256 MB Points totaux : 100

#2108. 装配工

Statistiques

Bajtazar 承担了 $n$ 部信息学奥林匹克竞赛题目讲解视频的剪辑工作。已知剪辑第 $i$ 部视频需要 $t_i$ 个连续的天数,且必须在第 $d_i$ 天结束前发布。Bajtazar 可以使用高速光纤网络,因此视频剪辑完成后会立即发布到奥赛服务器上。然而,剪辑工作对硬件要求很高,而 Bajtazar 只有一台电脑,因此同一时间只能剪辑一部视频。

视频数量很多,Bajtazar 担心无法按时完成所有任务。请你帮助他确定他最多能按时发布多少部视频,并给出实现该结果的计划。假设剪辑工作最早可以从第 1 天开始。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 500\,000$),表示需要剪辑的视频数量。

接下来的 $n$ 行描述了这些视频;第 $i$ 行包含两个整数 $t_i$ 和 $d_i$ ($1 \le t_i, d_i \le 10^9$),分别表示第 $i$ 部视频的剪辑时长和发布截止日期。

输出格式

程序应在第一行输出一个整数 $m$,表示 Bajtazar 最多能按时完成的视频数量。

接下来的 $m$ 行应记录工作计划;第 $i$ 行应包含两个整数 $f_i$ 和 $k_i$ ($1 \le f_i \le n, 1 \le k_i$),表示编号为 $f_i$ 的视频应从第 $k_i$ 天开始剪辑。

如果存在多个达到最大值 $m$ 的方案,输出其中任意一个即可。

样例

输入 1

5
4 5
2 4
5 3
1 9
3 10

输出 1

3
2 3
4 7
5 8

子任务

测试集分为以下子任务。每个子任务的测试用例由一组或多组独立的测试数据组成。如果你的程序正确输出了第一行(即 $m$ 的值),但后续行不正确,则该测试点可获得 50% 的分数。

子任务 条件 分值
1 $n \le 10$ 20
2 $n \le 1000$ 30
3 $t_i, d_i \le 10^6$ 20
4 无额外限制 30

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.