#B3824. Maximizing Sausage Tasty Value
Maximizing Sausage Tasty Value
Maximizing Sausage Tasty Value
Aya wants to purchase a desktop grilled sausage package for a barbecue. There are two brands available:
- Brand A: Each package contains $a$ sausages, costs $b$ yuan, and each sausage has a tasty value of $c$.
- Brand B: Each package contains $d$ sausages, costs $e$ yuan, and each sausage has a tasty value of $f$.
She only has $k$ yuan and can only buy an integer number of packages from one brand. Help Aya determine the maximum total tasty value she can get by choosing one brand optimally. The total tasty value from buying a number of packages is computed as follows:
- For Brand A: $\text{total} = \left\lfloor \frac{k}{b} \right\rfloor \times a \times c$
- For Brand B: $\text{total} = \left\lfloor \frac{k}{e} \right\rfloor \times d \times f$
Output the maximum total tasty value achievable.
inputFormat
The input consists of a single line containing seven space-separated integers: a b c d e f k
.
- $a$: Number of sausages per package for Brand A.
- $b$: Price per package for Brand A.
- $c$: Tasty value per sausage for Brand A.
- $d$: Number of sausages per package for Brand B.
- $e$: Price per package for Brand B.
- $f$: Tasty value per sausage for Brand B.
- $k$: Total money available.
outputFormat
Output a single integer representing the maximum total tasty value that Aya can achieve.
sample
2 4 3 3 5 4 20
48