No.31 Evil Mixed Juice
Problem Statement
The mixed juice has run out.
The ingredient label of the mixed juice lists, in order, fruit \(1\), fruit \(2\), \(\ldots\), fruit \(N\).
You want to make exactly \(V\) liters of mixed juice by mixing the existing 100% juices of each fruit.
The 100% juice of fruit \(k\) is sold only in \(1\)-liter packs, at \(C_k\) yen per \(1\) pack.
Write a program that finds the minimum cost of making \(V\) liters of mixed juice without changing the ingredient label.
That is, the proportions \(p_k\) that fruit \(k\) occupies in the mixed juice must satisfy \(p_1 \geq p_2 \geq \cdots \geq p_N\), and furthermore, no fruit may be left unused.
It is also possible to buy a \(1\)-liter pack and use only part of it.
Input
\(N\) \(V\) \(C_1\) \(C_2\) ... \(C_N\)
Line \(1\) contains an integer \(N\ (1 \leq N \leq 100)\) representing the number of kinds of fruit and an integer \(V\ (1 \leq V \leq 10^9)\) representing the amount of mixed juice you want to make.
Line \(2\) contains, in order and separated by spaces, integers \(C_k\ (1 \leq C_k \leq 10^9)\) representing the price of a \(1\)-liter pack of the 100% juice of fruit \(k\).
Output
Output an integer representing the minimum cost (in yen) on \(1\) line. Print a newline at the end.
Sample
Sample 1
Input
3 10 1 100 100
Output
208
It is optimal to mix \(8\) liters of fruit \(1\) and \(1\) liter each of fruits \(2,3\).
Sample 2
Input
3 10 100 1 100
Output
604
It is optimal to mix \(5\) liters of fruit \(1\), \(4\) liters of fruit \(2\), and \(1\) liter of fruit \(3\).
Sample 3
Input
3 10 100 100 1
Output
703
It is optimal to mix \(4\) liters of fruit \(1\), \(3\) liters of fruit \(2\), and \(3\) liters of fruit \(3\).
Sample 4
Input
3 1 100 100 100
Output
300
For example, you can buy a \(1\)-liter pack of each of all \(3\) fruits and mix \(0.5\) liters of fruit \(1\), \(0.3\) liters of fruit \(2\), and \(0.2\) liters of fruit \(3\).
Sample 5
Input
9 36 459473288 389234620 200824516 103210888 47314058 533584454 391380554 875989889 257188584
Output
10107195609
Note that the answer may exceed \(2^{32}\).
It is optimal to mix \(7\) liters each of fruits \(1,2\), \(6\) liters each of fruits \(3,4,5\), and \(1\) liter each of fruits \(6,7,8,9\).
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
LayCurse