問題一覧 > 通常問題

No.31 Evil Mixed Juice

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 100
作問者 : LayCurse
お気に入りにしたユーザー ProblemId : 3 / 自分の提出
問題文最終更新日: 2026-06-27 00:47:40
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 31 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。