Loading Now

giftSet

After Christmas, end year is coming, the owner of the grocery store – Van have ordered a new delivery for his store to be able to get more money and hope that enough to buy some pork.

This delivery consists of a wine bottles, b beer packs, c jam boxes and d tea bags.

The store does not sell single items. Instead, it sells combos of two types below:

  • A combo of the first type consists of 1 wine and 1 tea bag;
  • A combo of the second type consists of 1 beer pack, 1 jam box and 1 tea bag.

Each combo of the first type costs e coins, and each combo of the second type costs f coins.

Calculate the maximum possible cost of a set of combos that can be composed from the delivered items.

Note that one item cannot be used in more than one set (some items may not be used).

Example:

  • For a = 4, b = 5, c = 6, d = 3, e = 1, f = 2, the output should be giftSet(a, b, c, d, e, f) = 6.
    It is possible to compose 3 combos of the second type in the example, and their total cost will be 6.
    Since all tea bags will be used, it’s impossible to add anything to this set.

Input/Output:

  • [Execution time limit] 0.1s in C++, 1s in Java, C#, Python, GO and Js.
  • [Input] integers a
    The number of wine bottles.
    1 ≤ a ≤ 10000
  • [Input] integers b
    The number of beer packs
    1 ≤ b ≤ 100000
  • [Input] integers c
    The number of jam boxes.
    1 ≤ c ≤ 100000
  • [Input] integers d
    The number of tea bags.
    1 ≤ d ≤ 100000
  • [Input] integers e
    The cost of one combo of the first type.
    1 ≤ e ≤ 1000
  • [Input] integers f
    The cost of one combo of the second type.
    1 ≤ f ≤ 1000 
  • [Output] integer
    The maximum total cost of some set of combos that can be composed from the delivered items.

Post Comment

Contact