atcoder#ABC297E. [ABC297E] Kth Takoyaki Set
[ABC297E] Kth Takoyaki Set
Score : points
Problem Statement
In AtCoder Kingdom, kinds of takoyakis (ball-shaped Japanese food) are sold. A takoyaki of the -th kind is sold for yen.
Takahashi will buy at least one takoyaki in total. He is allowed to buy multiple takoyakis of the same kind.
Find the -th lowest price that Takahashi may pay. Here, if there are multiple sets of takoyakis that cost the same price, the price is counted only once.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
4 6
20 25 30 100
50
The four kinds of takoyakis sold in AtCoder Kingdom cost yen, yen, yen, and yen.
The six lowest prices that Takahashi may pay are yen, yen, yen, yen, yen, and yen. Thus, the answer is .
Note that at least one takoyaki must be bought.
2 10
2 1
10
Note that a price is not counted more than once even if there are multiple sets of takoyakis costing that price.
10 200000
955277671 764071525 871653439 819642859 703677532 515827892 127889502 881462887 330802980 503797872
5705443819