题目收集
题目列表题单
返回列表

Cross

CodeforcesP0015· 1000ms· 512 MB· ZJU Summer 2026 Contest 1原题链接
贪心模拟

创建于 2026/07/16 · 更新于 2026/07/16

题目描述

You need to maximize the total decrease in a target's Health Points (HP) over an nnn-round process. The total HP decrease can be negative (meaning the target's HP increased overall).

Initially, there are two parameters r=0r = 0r=0 and c=0c = 0c=0. Over the course of nnn rounds, in round iii (1≤i≤n1 \le i \le n1≤i≤n), the following events occur sequentially:

  1. The parameter rrr is increased by aia_iai​.
  2. You may choose to use a skill. If you use the skill, ccc is increased by 111, and rrr is decreased by 111 (if r=0r = 0r=0, it cannot be decreased, but the skill can still be used and ccc will still increase). Note that you can use this skill at most KKK times across all nnn rounds.
  3. The target recovers r×Rr \times Rr×R HP.
  4. You deal XXX fixed damage to the target.
  5. The target takes c×Cc \times Cc×C continuous damage.

You need to output the maximum possible total HP decrease.

Note that you do not care about the intermediate HP values during the process; you only care about the difference between the target's initial HP and final HP after all nnn rounds.

输入格式

The first line contains 555 integers n,K,R,X,Cn, K, R, X, Cn,K,R,X,C, representing the number of attack rounds, the maximum number of skill uses, the continuous HP recovery multiplier, the fixed damage per attack, and the continuous damage multiplier, respectively.

The second line contains nnn non-negative integers. The iii-th integer is aia_iai​, representing the number of times the recovery effect is applied in round iii.

For all testcases, 1≤K≤n≤2×1061 \le K \le n \le 2 \times 10^61≤K≤n≤2×106, 0≤X,R,C,ai≤1060 \le X, R, C, a_i \le 10^60≤X,R,C,ai​≤106.

输出格式

Output a single integer, representing the maximum possible decrease in the target's HP.

样例输入 #1

5 3 1 2 3
1 0 2 0 0

样例输出 #1

43

样例输入 #2

5 3 3 3 4
0 1 0 4 4

样例输出 #2

29

样例输入 #3

8 1 9 2 8
0 0 0 1 1 10 10 10

样例输出 #3

-520