CF526C.Om Nom and Candies
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
一个可爱的小怪物欧姆·诺姆非常喜欢糖果。一天,他陷入了一个相当棘手的境地,需要稍加思考才能尽可能多地享受糖果。如果你处在他的位置,你能成功完成同样的任务吗?

有一天,当他来到朋友埃文家时,欧姆·诺姆发现埃文并不在家,但他在屋里发现了两袋糖果:第一袋装满了蓝色糖果,第二袋装满了红色糖果。欧姆·诺姆知道每颗红色糖果重 Wr 克,每颗蓝色糖果重 Wb 克;吃一颗红色糖果能给他带来 Hr 点快乐值,而吃一颗蓝色糖果能给他带来 Hb 点快乐值。
糖果是世界上最重要之物,但另一方面,暴饮暴食却有害健康。欧姆·诺姆知道:如果他摄入的糖果总重量超过 C 克,他就会生病。欧姆·诺姆认为留下未吃完的糖果是不妥的,因此他只能整颗整颗地吃糖果(即不能将单颗糖果切开食用)。欧姆·诺姆是一位杰出的数学家,他迅速算出了应各吃多少颗红色与蓝色糖果,才能获得最多的快乐值。你能否重现他的这一成就?你可以假设每袋糖果的数量都远超欧姆·诺姆所能吃的总量。
输入格式
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 ≤ 109).
单行包含五个整数 C、Hr、Hb、Wr、Wb(1≤C,Hr,Hb,Wr,Wb≤109)。
输出格式
Print a single integer — the maximum number of joy units that Om Nom can get.
输出一个整数——Om Nom 能获得的最大快乐值。
输入输出样例
输入#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.
在样例测试中,Om Nom 可以吃每种糖果各两颗,从而获得 16 点快乐值。
输入解题思路,AI测评打分。不知道怎么写?