E. Monster Invaders SOLUTIONS

Monster Invaders SOLUTION Codeforces

Ziota found a computer game called “Beast Invaders”. Like each other shooting RPG game, “Beast Invaders” includes slaughtering beasts and managers with weapons. For straightforwardness, we just think about two unique sorts of beasts and three distinct kinds of firearms. Specifically, the two sorts of beasts are: 
 
an ordinary beast with 1 hp. 
 
a manager with 2 hp. 
 
Furthermore, the three sorts of weapons are: 
 
Gun, bargains 1 hp in harm to one beast, r1 reloading time 
 
Laser firearm, bargains 1 hp in harm to all the beasts in the current level (counting the chief), r2 reloading time 
 
AWP, immediately kills any beast, r3 reloading time 
 
The weapons are at first not stacked, and the Ziota can just reload 1 firearm at once. 
 
The degrees of the game can be considered as a cluster a1,a2,… ,a, where the I-th stage has ai typical beasts and 1 chief. Because of the idea of the game, Ziota can’t utilize the Pistol (the principal kind of firearm) or AWP (the third sort of weapon) to shoot the manager before slaughtering the entirety of the ai typical beasts. 
 
In the event that Ziota harms the chief yet doesn’t execute it quickly, he is compelled to move out of the current level to a self-assertive nearby level (contiguous degrees of level I (1<i<n) are levels i−1 and i+1, the main neighboring degree of level 1 is level 2, the main adjoining level of level n is level n−1). Ziota can likewise decide to move to a nearby level whenever. Each move between adjoining levels are overseen by gateways with d teleportation time. 
 
All together not to upset the space-time continuum inside the game, it is carefully illegal to reload or shoot beasts during teleportation. 
 
Ziota begins the game at level 1. The target of the game is somewhat basic, to slaughter all the supervisors in all the levels. He is interested about the base opportunity to complete the game (accepting it takes no effort to shoot the beasts with a stacked firearm and Ziota has interminable ammunition on all the three weapons). It would be ideal if you assist him with discovering this worth. 
 
Information 
 
The principal line of the information contains five numbers isolated by single spaces: n (2≤n≤106) — the quantity of stages, r1,r2,r3 (1≤r1≤r2≤r3≤109) — the reload season of the three weapons individually, d (1≤d≤109) — the hour of moving between neighboring levels. 
 
The second line of the info contains n whole numbers isolated by single spaces a1,a2,… ,a (1≤ai≤106,1≤i≤n). 
 
Yield 
 
Print one number, the base opportunity to complete the game. 
 
Models 
 
inputCopy 
 
4 1 3 4 3 
 
3 2 5 1 
 
outputCopy 
 
34 
 
inputCopy 
 
4 2 4 1 
 
4 5 1 2 
 
outputCopy 
 
31 
 
Note 
 
In the main experiment, the ideal procedure is: 
 
Utilize the gun to kill three typical beasts and AWP to kill the chief (Total time 1⋅3+4=7) 
 
Move to arrange two (Total time 7+3=10) 
 
Utilize the gun twice and AWP to kill the chief (Total time 10+1⋅2+4=16) 
 
Move to organize three (Total time 16+3=19) 
 
Utilize the laser firearm and compelled to move to either organize four or two, here we move to arrange four (Total time 19+3+3=25) 
 
Utilize the gun once, use AWP to kill the chief (Total time 25+1⋅1+4=30) 
 
Move back to arrange three (Total time 30+3=33) 
 
Kill the supervisor at stage three with the gun (Total time 33+1=34) 
 
Note that here, we don’t complete at level n, yet when all the managers are executed.

Leave a Comment

close
error: Content is protected !!
Free Udemy Courses and Hacking Resources Join Us on TelegramClick Here
+