A9797 | Om Nom and Candies
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted