#P3628. [APIO2010] 特别行动队
[APIO2010] 特别行动队
Description
You command a unit consisting of reserve soldiers, numbered from to . You need to split them into several commando teams to be deployed to the battlefield. For teamwork reasons, the indices of the members within the same commando team must be consecutive, i.e., a sequence of the form . Every soldier must belong to exactly one commando team.
The initial combat power of soldier is . The initial combat power of a commando team is the sum of the initial combat power of its members, i.e., .
From long-term observation, you have summarized that for a commando team with initial combat power , its adjusted combat power is , where are known coefficients (). As the commander, you must form the teams so that the sum of adjusted combat power over all commando teams is maximized. Find this maximum sum.
Input Format
The first line contains an integer , the number of soldiers.
The second line contains three space-separated integers, , which are the coefficients of the adjusted combat power formula.
The third line contains space-separated integers, where the -th integer is the initial combat power of soldier .
Output Format
Output a single integer on one line, the maximum possible sum of adjusted combat power over all commando teams.
4
-1 10 -20
2 2 3 4
9
Hint
Explanation of Sample Input/Output 1
You have soldiers, . The parameters in the adjusted combat power formula are .
The optimal plan is to form commando teams: the first team contains soldiers and , the second team contains soldier , and the third team contains soldier . The initial combat powers of the teams are , and the adjusted combat powers are , , . The sum of adjusted combat powers is , and no other plan yields a larger sum.
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号