No.2386 Udon Coupon (Easy)
タグ : / 解いたユーザー数 214
作問者 :
GlinTFraulein
/ テスター :
cleantted
tatyam
PCTprobability
amentorimaru
Problem Statement
At a certain udon restaurant, you can receive discounts by using some "udon coupons".
There are the following $3$ types of discounts.
- Use $3$ "udon coupons" to receive a discount of $A$ yen
- Use $5$ "udon coupons" to receive a discount of $B$ yen
- Use $10$ "udon coupons" to receive a discount of $C$ yen
These discounts can be received any number of times as long as you have "udon coupons", but the "udon coupons" used are consumed.
Now, Midori wants to use her "udon coupons" to receive as large a discount as possible. Given that she has $N$ "udon coupons", output the maximum total discount amount $D$.
Constraints
- $1 \le N \le 2 \times 10^5$
- $1 \le A \lt B \lt C \le 1000$
- All inputs are integers
Input
$N$ $A$ $B$ $C$
Output
$D$
Output the maximum total discount amount $D$.
Sample
Sample 1
Input
16 90 100 390
Output
570
- Use $3$ "udon coupons" to receive a discount of $90$ yen.
- Use $3$ "udon coupons" to receive a discount of $90$ yen once more.
- Use $10$ "udon coupons" to receive a discount of $390$ yen.
The total discount is $570$ yen. No larger discount can be achieved.
Sample 2
Input
2 800 900 1000
Output
0
There may be cases where not all "udon coupons" can be consumed, or where not even $1$ can be used.
Sample 3
Input
314 159 265 358
Output
16642
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。