#P10747. [SEERC 2020] Neo-Robin Hood
[SEERC 2020] Neo-Robin Hood
Problem Description
You are a thief. There are households in the town. For each household , you choose one of the following options.
-
Steal dollars from them, and they will start hating you.
-
Give them dollars, and they will make one person you have stolen from cancel their hatred toward you.
-
Do nothing.
Initially, you have no money. You want to know: while ensuring that nobody hates you and the amount of money you have is non-negative, what is the maximum number of households you can steal from.
Note: You may visit the households one by one in any order.
Input Format
The first line contains an integer .
The second line contains a sequence of length .
The third line contains a sequence of length .
Output Format
Output the maximum number of households you can steal from.
5
2 3 4 5 6
1 2 3 4 5
2
4
1 2 4 2
5 6 9 7
0
4
9 19 6 5
20 3 16 19
1
Hint
Translated by ChatGPT 5