[USACO08MAR] River Crossing S

题意翻译

### 题目描述 农夫约翰以及他的 $N(1 \le N \le 2500)$ 头奶牛打算过一条河,但他们所有的渡河工具,仅仅是一个木筏。 由于奶牛不会划船,在整个渡河过程中,约翰必须始终在木筏上。在这个基础上,木筏上的奶牛数目每增加 $1$,FJ把木筏划到对岸就得花更多的时间。 当约翰一个人坐在木筏上,他把木筏划到对岸需要 $M(1 \le M \le 1000)$ 分钟。当木筏搭载的奶牛数目从 $i-1$ 增加到 $i$ 时,约翰得多花 $M_i(1 \le M_i \le 1000)$ 分钟才能把木筏划过河(也就是说,船上有 $1$ 头奶牛时,约翰得花 $M+M_1$ 分钟渡河;船上有 $2$ 头奶牛时,时间就变成 $M+M_1+M_2$ 分钟。后面的以此类推)。那么,约翰最少要花多少时间,才能把所有奶牛带到对岸呢?当然,这个时间得包括约翰一个人把木筏从对岸划回来接下一批的奶牛的时间。 ### 输入格式 * 第一行包含 $2$ 个整型变量 $N$ 和 $M$。 * 第二行包含 $2 ... N + 1$ 个整数,第 $i + 1$ 行包含 $1$ 个整数 $M_i$。 ### 输出格式 * 输出共 $1$ 行,为农夫约翰让所有奶牛过河所需的最短时间。

题目描述

Farmer John is herding his N cows (1 <= N <= 2,500) across the expanses of his farm when he finds himself blocked by a river. A single raft is available for transportation. FJ knows that he must ride on the raft for all crossings and that that adding cows to the raft makes it traverse the river more slowly. When FJ is on the raft alone, it can cross the river in M minutes (1 <= M <= 1000). When the i cows are added, it takes M\_i minutes (1 <= M\_i <= 1000) longer to cross the river than with i-1 cows (i.e., total M+M\_1 minutes with one cow, M+M\_1+M\_2 with two, etc.). Determine the minimum time it takes for Farmer John to get all of the cows across the river (including time returning to get more cows).

输入输出格式

输入格式


\* Line 1: Two space-separated integers: N and M \* Lines 2..N+1: Line i+1 contains a single integer: M\_i

输出格式


\* Line 1: The minimum time it takes for Farmer John to get all of the cows across the river.

输入输出样例

输入样例 #1

5 10 
3 
4 
6 
100 
1 

输出样例 #1

50 

说明

There are five cows. Farmer John takes 10 minutes to cross the river alone, 13 with one cow, 17 with two cows, 23 with three, 123 with four, and 124 with all five. Farmer John can first cross with three cows (23 minutes), then return (10 minutes), and then cross with the last two (17 minutes). 23+10+17 = 50 minutes total.