Mixture (Small)
Time limit1sMemory limit256 MB
Find the amounts of two mixtures a and b maximizing revenue under shared material limits, then round the optimum to two decimals.
- Level
Medium6 of 10
- Topics
- Geometry, Brute force, Math, Greedy
- Solved
- No attempts yet
Problem
Dahyun works as an undergraduate research assistant at a laboratory and has found a way to make two substances nobody has made before. Call them A and B. Both are made by mixing materials in fixed proportions. One gram of A is worth , and one gram of B is worth .
Making 1 g of A uses g of , and making 1 g of B uses g of . Every material is rare, and only g of is left. You may make any nonnegative real number of grams of A and of B, and the materials are used in proportion to the amounts made. If you make g of A and g of B, then must hold for every , and the value you get is .
Write a program that computes the largest value obtainable from the materials on hand, and how much A and how much B to make to obtain it.
Input
The first line contains , , .
The second line contains , the third line contains , and the fourth line contains .
Every number other than is a natural number between 1 and 1000000.
The limit on is as follows.
Output
On the first line, print the largest value obtainable, rounded to two decimal places.
On the second line, print the amount of A and the amount of B to make in order to obtain the maximum, each rounded to two decimal places and separated by one space.
Round the exact value: if the part left below the second decimal place is 0.005 or more, round up.
If several plans obtain the maximum value, print the one with the smallest amount of A. Once the amount of A is fixed, the amount of B is fixed too.