#P7097. [yLOI2020] 牵丝戏
[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 value. The value increases according to the types and quantities of items the player uses during a turn. We define player ’s turn as the whole process from launching an attack to the end of that turn. During player ’s turn, only player can use items and attack, and player will definitely attack. After a player’s turn ends, the next turn belongs to the player whose value is smaller. If the two players’ values are equal, since Fusu pays a lot, the next turn is definitely Fusu’s turn.
There are kinds of items in this game. Using the -th item increases the damage of this turn by times the base damage that does not count other items, and also increases the value by . 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 value will definitely increase by .
Item usage is restricted by the difference between the two players’ values. Specifically, in any turn, the items used must ensure that after the turn ends, the absolute difference between the two players’ values (including the guaranteed increase to the attacking player’s value) is no more than . An obvious fact is that as long as , 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 , her initial value is , and , and she uses two items with , , , , then the damage she deals this turn is
$$t + t \times k_1 + t \times k_2 = 10^5 + 114 + 514 = 100628$$Her value after the turn ends is
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
Her value after that next turn ends is
Now Fusu and Fugugu are fighting. Given the item list of the game, and their base damage and values, the game will last for a total of 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 of this test point.
The second line contains three integers: the number of turns , the number of items , and the fixed increase per turn .
The third line contains integers, where the -th integer is .
The fourth line contains integers, where the -th integer is .
The fifth line contains four integers, in order: Fusu’s initial base damage , Fugugu’s initial base damage , Fusu’s initial value , and Fugugu’s initial value .
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 value is and Fugugu’s value is , so turn 1 is Fusu’s. Fusu does not use any items, the damage is , his value increases by , and the total damage difference is .
- After turn 1 ends, both players’ values are , so turn 2 is Fusu’s. Fusu uses the first item, the damage is , his value increases by , and the total damage difference is .
- After turn 2 ends, Fusu’s value is and Fugugu’s value is , so turn 3 is Fugugu’s. Fugugu uses items and , the damage is , her value increases by , and the total damage difference is . After this turn ends, the value difference is exactly , which satisfies the requirement.
Constraints and Conventions
This problem uses bundled multiple testdata.
- Subtask ( points): guaranteed .
- Subtask ( points): guaranteed .
- Subtask ( points): guaranteed .
- Subtask ( points): guaranteed .
- Subtask ( points): guaranteed .
- Subtask ( points): no special constraints.
For all test points, it is guaranteed that , , , , and are multiples of , .
Notes
There are 4 sample files in total; please see opera.zip in the additional files.
For sample 2, .
For sample 3, .
Translated by ChatGPT 5