cswork / OAOpen practice workspace

IBMOA #35

Get Minimum Cost

Estimated EasyJudge-ready

Topics (AI-labelled)Bits & MathGreedy

A and B can be bought individually, or as a bundle containing one A and one B. You need at least x of A and y of B and may buy more than needed; find the minimum cost.

Input

One line containing costA costB costAB x y, each an integer in 1..10^9.

Output

Output one integer, the answer.

Example 1

Input:

3 4 2 2 1

Output:

4

Example 2

Input:

3 4 10 2 1

Output:

10

Example 3

Input:

9 9 1 1 3

Output:

3

Example notes

The examples give 4, 10 and 3 respectively; the first and third examples rely on buying extra equipment.

Editorial

Loading solution…