302708: CF526C. Om Nom and Candies

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Om Nom and Candies

题意翻译

【题目描述】 桌子上有无限多的红糖果与蓝糖果,每个红糖果重 $ W_{r} $ 克,而每个蓝糖果重 $ W_{b} $ 克。吃一颗红糖果可以获得 $ H_{r} $ 的快乐值,吃一颗蓝糖果可以获得 $ H_{b} $ 的快乐值。 在只能吃 $ C $ 克糖果的前提下,请求出能获得的最大快乐值。 【输入格式】 五个整数:$ C,H_{r},H_{b},W_{r},W_{b} $($1 \leq C,H_{r},H_{b},W_{r},W_{b} \leq 10^9$) 【输出格式】 出输出一个整数:能达到的最大快乐值。

题目描述

A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place? ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF526C/c14c5f059e5963812d81028fb21236fb5136bd2e.png)One day, when he came to his friend Evan, Om Nom didn't find him at home but he found two bags with candies. The first was full of blue candies and the second bag was full of red candies. Om Nom knows that each red candy weighs $ W_{r} $ grams and each blue candy weighs $ W_{b} $ grams. Eating a single red candy gives Om Nom $ H_{r} $ joy units and eating a single blue candy gives Om Nom $ H_{b} $ joy units. Candies are the most important thing in the world, but on the other hand overeating is not good. Om Nom knows if he eats more than $ C $ grams of candies, he will get sick. Om Nom thinks that it isn't proper to leave candy leftovers, so he can only eat a whole candy. Om Nom is a great mathematician and he quickly determined how many candies of what type he should eat in order to get the maximum number of joy units. Can you repeat his achievement? You can assume that each bag contains more candies that Om Nom can eat.

输入输出格式

输入格式


The single line contains five integers $ C,H_{r},H_{b},W_{r},W_{b} $ ( $ 1<=C,H_{r},H_{b},W_{r},W_{b}<=10^{9} $ ).

输出格式


Print a single integer — the maximum number of joy units that Om Nom can get.

输入输出样例

输入样例 #1

10 3 5 2 3

输出样例 #1

16

说明

In the sample test Om Nom can eat two candies of each type and thus get $ 16 $ joy units.

Input

题意翻译

【题目描述】 桌子上有无限多的红糖果与蓝糖果,每个红糖果重 $ W_{r} $ 克,而每个蓝糖果重 $ W_{b} $ 克。吃一颗红糖果可以获得 $ H_{r} $ 的快乐值,吃一颗蓝糖果可以获得 $ H_{b} $ 的快乐值。 在只能吃 $ C $ 克糖果的前提下,请求出能获得的最大快乐值。 【输入格式】 五个整数:$ C,H_{r},H_{b},W_{r},W_{b} $($1 \leq C,H_{r},H_{b},W_{r},W_{b} \leq 10^9$) 【输出格式】 出输出一个整数:能达到的最大快乐值。

加入题单

算法标签: