#P7097. [yLOI2020] 牵丝戏

    ID: 8014 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划 DP博弈论2020O2优化背包 DP

[yLOI2020] 牵丝戏

Background

In the wind and snow, autumn-white hair ends faintly show; lights glow lushly, wrinkling your brows.
If you give up a tear, if I grow old, I can stay with you.
Turn to ash in the misty waves, yet still leave perfectly.

— Yinlin & Aki Ajie, “牵丝戏”.

Problem Description

Fusu and Fugugu have recently been playing a game called “ddt”. Because “牵丝戏” is played on repeat while playing “ddt”, whenever they think of “牵丝戏”, they think of this game.

To simplify the problem, we consider it a 1v1 turn-based game. Each player has an attribute called the delay value, abbreviated as the dd value. The dd value increases according to the types and quantities of items the player uses during a turn. We define player xx’s turn as the whole process from launching an attack to the end of that turn. During player xx’s turn, only player xx can use items and attack, and player xx will definitely attack. After a player’s turn ends, the next turn belongs to the player whose dd value is smaller. If the two players’ dd values are equal, since Fusu pays a lot, the next turn is definitely Fusu’s turn.

There are mm kinds of items in this game. Using the ii-th item increases the damage of this turn by ki105\frac{k_i}{10^5} times the base damage that does not count other items, and also increases the dd value by pip_i. In each turn, each kind of item can be used at most once, and items used in this turn do not provide any damage bonus to the next turn. Also, after each turn ends, the attacking player’s dd value will definitely increase by ww.

Item usage is restricted by the difference between the two players’ dd values. Specifically, in any turn, the items used must ensure that after the turn ends, the absolute difference between the two players’ dd values (including the guaranteed ww increase to the attacking player’s dd value) is no more than 100100. An obvious fact is that as long as w100w \le 100, a player will always have some way to choose items (including choosing none) to satisfy this restriction.

For example, in Fugugu’s turn, if her base damage is t=105t=10^5, her initial dd value is d0=3d_0=3, and w=2w=2, and she uses two items with k1=114k_1=114, k2=514k_2=514, p1=19p_1=19, p2=81p_2=81, then the damage she deals this turn is

$$t + t \times k_1 + t \times k_2 = 10^5 + 114 + 514 = 100628$$

Her dd value after the turn ends is

d0+w+p1+p2=3+2+19+81=105d_0 + w + p_1 + p_2 = 3 + 2 + 19 + 81 = 105

If the next turn is still her turn and she does not use any items, then the damage she deals in the next turn is

t=100000t = 100000

Her dd value after that next turn ends is

105+w=105+2=107105 + w = 105 + 2 = 107

Now Fusu and Fugugu are fighting. Given the item list of the game, and their base damage and dd values, the game will last for a total of nn turns. Assume that no matter how much damage is dealt, neither side will die. Please maximize the value of “damage dealt by Fusu to Fugugu - damage dealt by Fugugu to Fusu”.

Of course, Fugugu will also try her best to maximize the value of “damage dealt by her to Fusu - damage dealt by Fusu to her”. Assume Fusu is the smartest boy in the yLOI world and Fugugu is the smartest girl in the yLOI world, meaning they will both choose the optimal strategy to use items and will not make mistakes. What you need to output is the maximum damage difference under this condition.

Input Format

The first line contains an integer indicating the subtask index TT of this test point.
The second line contains three integers: the number of turns nn, the number of items mm, and the fixed dd increase per turn ww.
The third line contains mm integers, where the ii-th integer is kik_i.
The fourth line contains mm integers, where the ii-th integer is pip_i.
The fifth line contains four integers, in order: Fusu’s initial base damage xax_a, Fugugu’s initial base damage xbx_b, Fusu’s initial dd value dad_a, and Fugugu’s initial dd value dbd_b.

Output Format

Output one line with one integer, the answer.

0
3 2 1
50 1
20 100
100000 200000 2 3
-52

Hint

Sample 1 Explanation

  • Before turn 1 starts, Fusu’s dd value is 22 and Fugugu’s dd value is 33, so turn 1 is Fusu’s. Fusu does not use any items, the damage is 100000100000, his dd value increases by 11, and the total damage difference is 100000100000.
  • After turn 1 ends, both players’ dd values are 33, so turn 2 is Fusu’s. Fusu uses the first item, the damage is 100050100050, his dd value increases by 2121, and the total damage difference is 200050200050.
  • After turn 2 ends, Fusu’s dd value is 2424 and Fugugu’s dd value is 33, so turn 3 is Fugugu’s. Fugugu uses items 11 and 22, the damage is 200102200102, her dd value increases by 121121, and the total damage difference is 52-52. After this turn ends, the dd value difference is exactly 100100, which satisfies the requirement.

Constraints and Conventions

This problem uses bundled multiple testdata.

  • Subtask 11 (55 points): guaranteed n=0n=0.
  • Subtask 22 (1010 points): guaranteed m=0m=0.
  • Subtask 33 (1515 points): guaranteed n,m5n,m \le 5.
  • Subtask 44 (2020 points): guaranteed n3n \le 3.
  • Subtask 55 (2020 points): guaranteed m10m \le 10.
  • Subtask 66 (3030 points): no special constraints.

For all test points, it is guaranteed that 0n1030 \le n \le 10^3, 0m1050 \le m \le 10^5, 1pi,w1001 \le p_i,w \le 100, 1xa,xb,ka,da,db1091 \le x_a,x_b,k_a,d_a,d_b \le 10^9, xax_a and xbx_b are multiples of 10510^5, 1dadb1001 \le |d_a-d_b| \le 100.

Notes

There are 4 sample files in total; please see opera.zip in the additional files.
For sample 2, m=0m = 0.
For sample 3, n3n \leq 3.

Translated by ChatGPT 5