QOJ.ac

QOJ

时间限制: 4 s 内存限制: 256 MB 总分: 100

#1654. 新罗宾汉

统计

在 Neverland 有 $n$ 位雄心勃勃的政客。他们很富有,但还不足以获得政治影响力。由于 Neverland 是一个财务透明的避风港,我们了解每位政客的银行账户:第 $i$ 位政客($1 \le i \le n$)拥有 $m_i$ 美元,并且需要 $p_i$ 美元才能实现他的政治目标。

你是臭名昭著的现代超级英雄“新罗宾汉”(Neo-Robin Hood)。你通过劫富济贫来谋生,以帮助……嗯,任何承诺回报你的人。对于每一位政客,你可以选择执行以下操作之一:

  1. 偷走他的 $m_i$ 美元;
  2. 对他什么都不做;
  3. 给他 $p_i$ 美元,帮助他获得政治影响力。

但你的服务不是免费的。一旦你帮助一位政客获得政治影响力,他就有义务帮你掩盖一次盗窃行为,这样你就不会惹上麻烦——例如,为你提供不在场证明。作为交换,你也必须承诺未来不再偷他的钱。

你最初没有任何钱。你的任务是尽可能多地抢劫政客;然而,你不能承担被抓的风险,因此你每犯下一次罪行,都需要一位政客为你承担责任。

你能抢劫的最大人数是多少?

输入格式

第一行包含一个正整数 $n$ ($1 \le n \le 100\,000$),表示政客的人数。 第二行包含 $n$ 个正整数 $m_i$ ($1 \le m_i \le 10^9$,对于所有 $1 \le i \le n$)。 第三行包含 $n$ 个正整数 $p_i$ ($1 \le p_i \le 10^9$,对于所有 $1 \le i \le n$)。

输出格式

输出一个非负整数,表示你能抢劫的最大人数。

注意,你不需要最大化你自己的财富,而是要最大化你抢劫的人数。

样例

样例输入 1

5
2 3 4 5 6
1 2 3 4 5

样例输出 1

2

样例输入 2

4
1 2 4 2
5 6 9 7

样例输出 2

0

样例输入 3

4
9 19 6 5
20 3 16 19

样例输出 3

1

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#314EditorialOpen题解jiangly2025-12-14 07:03:02View

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.