LCC '25 Contest 3 S1 - Holiday Assembly Line
View as PDFChristmas is coming up, and Santa needs to finish wrapping all his presents! He must purchase equipment to establish some assembly lines and hire elves to operate them. When hiring elves, Santa can either place them at an already existing assembly line, or he can open up a new assembly line and place the elf there. The cost of hiring the
elf to work at the
assembly line is
. Although Santa only has space for up to
assembly lines, he can have an unlimited number of elves working at any assembly line. What is the minimum total cost required to hire all
elves?
Input Specification
One line, containing four integers
Output Specification
Output the minimum total cost. Note that this number may be too large for a -bit integer.
Constraints
Subtask 1 [15%]
Subtask 2 [85%]
Sample Input 1
10 6 3 4
Output for Sample Input 1
70
Explanation of Output for Sample Input 1
Consider the following table, where the number in each cell represents the cost for hiring the elf to work at the
assembly line. As a reminder, cost =
.
The minimum cost to hire elves is shown by the boxed numbers.
.
Sample Input 2
3 5 4 2
Output for Sample Input 2
46
Comments