QOJ.ac

QOJ

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

#1654. 新羅賓漢

Statistiques

在 Neverland 有 $n$ 位雄心勃勃的政治家。他們很富有,但還不足以獲得政治影響力。由於 Neverland 是一個財務透明的避風港,我們知道每位政治家的銀行帳戶資訊:第 $i$ 位政治家($1 \le i \le n$)擁有 $m_i$ 美元,並且需要額外 $p_i$ 美元才能實現他的政治目標。

你是惡名昭彰的現代超級英雄「新羅賓漢」(Neo-Robin Hood)。你靠著從富人手中竊取財富來維生,以便幫助……嗯,任何承諾會回報你的人。對於這 $n$ 位政治家中的每一位,你可以選擇執行以下其中一項行動:

  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.