#P2672. [NOIP 2015 普及组] 推销员
[NOIP 2015 普及组] 推销员
Description
A Ming is a salesman. He is assigned to promote his company’s products on Screw Street. Screw Street is a dead-end; the exit and entrance are the same. One side of the street is a wall, and the other side has households. There are households on Screw Street, and the -th household is meters from the entrance. Because multiple households can live in the same building, several households may be at the same distance from the entrance. A Ming will enter from the entrance, promote products to households on Screw Street one by one, and then walk back along the same route.
For every meter he walks, he accumulates fatigue point. Promoting to the -th household accumulates fatigue points. A Ming is a workaholic. He wants to know, for different values of , under the premise of not walking any extra distance, what is the maximum total fatigue he can accumulate.
Input Format
The first line contains a positive integer , the number of households on Screw Street.
The next line contains non-negative integers; the -th integer is the distance from the -th household to the entrance. It is guaranteed that .
The next line contains positive integers; the -th integer is the fatigue accumulated by promoting to the -th household. It is guaranteed that .
Output Format
Output lines, each with one positive integer. The integer on the -th line denotes the maximum total fatigue when .
5
1 2 3 4 5
1 2 3 4 5
15
19
22
24
25
5
1 2 2 4 5
5 4 3 4 1
12
17
21
24
27
Hint
Explanation for Sample 1:
: promote to household . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
: promote to households . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
: promote to households . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
: promote to households . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
: promote to households . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
Explanation for Sample 2:
: promote to household . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
: promote to households . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
: promote to households . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
: promote to households . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is . Or promote to households . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
: promote to households . The round-trip walking fatigue is , the promotion fatigue is , and the total fatigue is .
Constraints:
For of the testdata, . For of the testdata, . For of the testdata, . For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号