#ABC478B. 配料 / Topping
配料 / Topping
Problem Statement
Takahashi is at a ramen shop.
This shop has kinds of toppings, and the -th topping has a price of and a happiness of .
Takahashi chooses three distinct kinds of toppings so that the total price is at most . Find the maximum possible total happiness of the toppings he chooses.
The constraints guarantee that there is at least one way to choose three distinct kinds of toppings so that the total price is at most .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output the answer in one line.
5 9
31 41 59 26 53
143
When choosing the first, third, and fifth toppings, the total price is , and the total happiness is .
10 16
102228 448944 131224 326172 500169 670309 976672 579051 974511 773940
2095925
When choosing the second, sixth, and seventh toppings, the total price is , and the total happiness is .
- Source: AtCoder ABC 478 B
相关
在下列比赛中: