#P11656. 「FAOI-R5」喷酒大赛
「FAOI-R5」喷酒大赛
Background
Fire spitting is a unique and mysterious stunt in Sichuan opera. It originated in ancient Western Shu and is famous across the Chinese opera world. Face-changing performers use magic-like skills to switch masks in an instant, and when combined with the strange art of fire spitting, it shows sharp changes in characters’ emotions and the plot, creating strong inner tension. This is one of the most powerful and romantic ways Sichuan opera portrays characters. During a performance, the actor holds a tube in their mouth. Inside the tube there is pine resin powder and paper ash that has not been completely burned out. (How much it is burned matters a lot: it must be burned out, but not fully burned out.) When fire is needed, it is lit from the outside, and the actor blows outward, making sparks spray out.
The Shaoxing opera fire-spitting show at the opening ceremony of WC2025 was amazing. Even though you have not learned fire spitting, you can spray liquor.
Problem Description
There are performers standing on a number line. The -th performer stands at position , where is a positive integer. Everyone holds strong liquor in their mouth. For the -th performer, you may give them one coin to make them perform liquor spraying.
After you pay, performers who did not receive money leave the stage. The remaining performers, at time , spray liquor from their mouths toward either left or right with intensity . Formally, the liquor sprayed by performer has a direction attribute , and you may set or . For time , at time the liquor’s position is . When , the liquor disappears.
Performers have special protection on their backs, but not on their fronts. If at some positive integer time , the liquor sprayed by performer still exists and there exists a remaining performer such that , then:
- If :
- If , the liquor sprayed by performer disappears.
- If , then , i.e. the liquor’s intensity decreases by .
- If , then performer gets sprayed by the liquor and angrily leaves.
You want the liquor to cover the positions on the number line. That is, for every , there exists at least one pair of nonnegative integers such that at time the liquor sprayed by performer still exists and . Find the minimum number of coins needed, under the conditions that this goal is achieved and no performer leaves angrily.
Input Format
The first line contains a positive integer , denoting the number of performers.
The second line contains positive integers. The -th number is , denoting the distance the -th performer’s liquor can spray.
The third line contains positive integers. The -th number is , denoting the intensity of the -th performer’s liquor.
Output Format
Output one positive integer in one line, denoting the minimum cost to cover .
10
1 1 4 5 1 4 1 2 1 2
1 1 2 0 3 1 2 0 2 1
3
10
1 1 9 2 4 9 2 2 1 1
1 0 3 2 3 0 3 8 2 1
3
24
1 4 5 2 3 1 4 2 5 3 1 1 1 3 2 1 1 1 1 2 2 1 1 3
1 1 4 0 3 0 0 4 0 5 3 2 0 3 2 1 0 3 2 0 0 2 1 1
10
Hint
Sample Explanation
- Sample #1: Give coins to performers , and set .
- Sample #2: Give coins to performers , and set .
Constraints and Notes
This problem uses bundled testdata.
- Subtask 1 (20 pts): .
- Subtask 2 (10 pts): , .
- Subtask 3 (15 pts): .
- Subtask 4 (20 pts): .
- Subtask 5 (15 pts): .
- Subtask 6 (20 pts): no special restrictions.
For all testdata, , .
Translated by ChatGPT 5