#P9363. Hotel Room Assignment Optimization

    ID: 22516 Type: Default 1000ms 256MiB

Hotel Room Assignment Optimization

Hotel Room Assignment Optimization

You are volunteering at an ancient hotel that lacks modern communication facilities. There are n teams, each with exactly 3 contestants. The hotel offers two types of rooms:

  • Single Room (capacity: 1 contestant)
  • Double Room (capacity: 2 contestants)

If two contestants share a double room, they must belong to the same team and have the same gender. Note that a double room can also accommodate a single contestant. The cost for each room depends on its type, and while all rooms of the same type cost the same, costs may differ between types.

Your task is to compute the minimum total cost required to assign all contestants to the hotel rooms without violating the rules. Since every team of 3 contestants must have at least one gender appearing twice (by the pigeonhole principle), it is always possible to pair two contestants from the same team if needed.

inputFormat

The input consists of a single line containing three integers n, S, and D, where:

  • n is the number of teams (each team has exactly 3 contestants).
  • S is the cost of a single room.
  • D is the cost of a double room.

outputFormat

Output a single integer representing the minimum total cost required to assign all contestants to the rooms.

sample

1 100 120
220