Monster Invaders

题意翻译

这是一个 RPG 枪战游戏。 有 $n$ 个关卡,每一个关卡都有 $a_i$ 个生命值为 $1$ 的小怪,$1$ 个生命值为 $2$ 的 boss。 有三种武器: + 手枪,可以对一个怪物造成 $1$ 点伤害,每次使用前需要 $r_{1}$ 秒装弹。 + 激光枪,可以对目前关卡所有怪物造成 $1$ 点伤害,每次使用前需要 $r_{2}$ 秒装弹。 + AWP(一种狙击枪),可以直接杀死任意怪物,每次使用前需要 $r_{3}$ 秒装弹。 由于游戏 $feature$,用手枪或 AWP 攻击 boss 前必须先杀死 boss 所在关卡的所有小怪。如果攻击 boss 但此次攻击并没有杀死 boss,必须移动到该关卡的相邻关卡。 除此之外,可以在任意时间移动到所在关卡的相邻关卡,每一次移动需要 $d$ 秒,此时什么都不能做。 从第一关开始游戏,游戏目标是击杀所有 boss,求完成游戏的最短时间。 ## 输入格式 第一行五个正整数 $n,r_1,r_2,r_3,d$,意义见题目描述。 第二行 $n$ 个正整数 $a_1,a_2,\dots,a_n$,表示每一关的小怪数量。 ## 输出格式 一行一个正整数,表示最短通关时间。 ## 数据规模&提示 - 对于 $100\%$ 的数据,$2\leq n\leq 10^6,1\leq r1\leq r2\leq r3\leq 10^9,1\leq d\leq 10^9,1\leq a_i\leq 10^6$ - 不要求在第 $n$ 个关卡结束游戏。 - 如果移动前该关卡里有没有杀死的敌人,回到这个关卡时敌人的状态不会发生变化。

题目描述

Ziota found a video game called "Monster Invaders". Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns. For the sake of simplicity, we only consider two different types of monsters and three different types of guns. Namely, the two types of monsters are: - a normal monster with $ 1 $ hp. - a boss with $ 2 $ hp. And the three types of guns are: - Pistol, deals $ 1 $ hp in damage to one monster, $ r_1 $ reloading time - Laser gun, deals $ 1 $ hp in damage to all the monsters in the current level (including the boss), $ r_2 $ reloading time - AWP, instantly kills any monster, $ r_3 $ reloading time The guns are initially not loaded, and the Ziota can only reload 1 gun at a time. The levels of the game can be considered as an array $ a_1, a_2, \ldots, a_n $ , in which the $ i $ -th stage has $ a_i $ normal monsters and 1 boss. Due to the nature of the game, Ziota cannot use the Pistol (the first type of gun) or AWP (the third type of gun) to shoot the boss before killing all of the $ a_i $ normal monsters. If Ziota damages the boss but does not kill it immediately, he is forced to move out of the current level to an arbitrary adjacent level (adjacent levels of level $ i $ $ (1 < i < n) $ are levels $ i - 1 $ and $ i + 1 $ , the only adjacent level of level $ 1 $ is level $ 2 $ , the only adjacent level of level $ n $ is level $ n - 1 $ ). Ziota can also choose to move to an adjacent level at any time. Each move between adjacent levels are managed by portals with $ d $ teleportation time. In order not to disrupt the space-time continuum within the game, it is strictly forbidden to reload or shoot monsters during teleportation. Ziota starts the game at level 1. The objective of the game is rather simple, to kill all the bosses in all the levels. He is curious about the minimum time to finish the game (assuming it takes no time to shoot the monsters with a loaded gun and Ziota has infinite ammo on all the three guns). Please help him find this value.

输入输出格式

输入格式


The first line of the input contains five integers separated by single spaces: $ n $ $ (2 \le n \le 10^6) $ — the number of stages, $ r_1, r_2, r_3 $ $ (1 \le r_1 \le r_2 \le r_3 \le 10^9) $ — the reload time of the three guns respectively, $ d $ $ (1 \le d \le 10^9) $ — the time of moving between adjacent levels. The second line of the input contains $ n $ integers separated by single spaces $ a_1, a_2, \dots, a_n $ $ (1 \le a_i \le 10^6, 1 \le i \le n) $ .

输出格式


Print one integer, the minimum time to finish the game.

输入输出样例

输入样例 #1

4 1 3 4 3
3 2 5 1

输出样例 #1

34

输入样例 #2

4 2 4 4 1
4 5 1 2

输出样例 #2

31

说明

In the first test case, the optimal strategy is: - Use the pistol to kill three normal monsters and AWP to kill the boss (Total time $ 1\cdot3+4=7 $ ) - Move to stage two (Total time $ 7+3=10 $ ) - Use the pistol twice and AWP to kill the boss (Total time $ 10+1\cdot2+4=16 $ ) - Move to stage three (Total time $ 16+3=19 $ ) - Use the laser gun and forced to move to either stage four or two, here we move to stage four (Total time $ 19+3+3=25 $ ) - Use the pistol once, use AWP to kill the boss (Total time $ 25+1\cdot1+4=30 $ ) - Move back to stage three (Total time $ 30+3=33 $ ) - Kill the boss at stage three with the pistol (Total time $ 33+1=34 $ ) Note that here, we do not finish at level $ n $ , but when all the bosses are killed.