### Aleph-null's blog

By Aleph-null, history, 2 months ago,

For problem this, the editorial suggests a naive way in which we break the chain and linearly kill all the monsters(then they present an optimization based on this), how do we know that this is the optimal way? Why can't I first kill monsters from one segment and then once the cascading effect stops, I jump to another monster which(say) has the highest b[i]/a[i] ratio? I need help in understanding this. Thanks in advance. (You can ask for further clarification from me if required)

• +5

 » 2 months ago, # |   0 Auto comment: topic has been updated by Aleph-null (previous revision, new revision, compare).
 » 2 months ago, # |   0 Once you kill the first monster, you are left with two segments and the cycle breaks (as described in the tutorial). When the cycle is broken, it makes no sense to shoot at a monster that is in the middle of the segment. This is because the explosion effect does not affect both adjacent monsters, only the next one. `when the health of some monster i becomes 0 or less than 0, it dies and explodes, dealing bi damage to the next monster (monster i+1, if i
•  » » 2 months ago, # ^ |   0 So basically what I understood after reading this and the editorial, once the chain is broken at a point, we cannot reach the points in front segment using the points in another segment (since the explosion will not affect them as the monster in between is already dead) and shooting the previous segment is suboptimal as the explosions from the first segment cycle over and reduce the cost of the second segment. Is that correct?
•  » » » 2 months ago, # ^ |   0 Kind of yes. I actually misunderstood something. When the first monster is killed, only one segment remains, but the cycle is broken. Instead, a line of monsters forms. So say u have 10 monsters labeled 1 to 10. Then, if u kill the 5th monster, u will have a line of monsters in the following order: 6 7 8 9 10 1 2 3 4. Now notice that the 6th monster (the monster which is first in the line) can never be affected by an explosion since the monster before it (5th monster) has already died. Therefore it is optimal to kill the 6th monster first. Using a similar logic, u can decipher that the order in which u kill the monsters is the order of the line. In this case (6 7 8 9 10 1 2 3 4). So the only thing that matters is the first monster that u kill. Then just greedily kill all the monsters in the order of the cycle.
•  » » » » 2 months ago, # ^ |   0 Got it, thank you :)