Amplitude Hackathon Summer '24 Problem 5 - Lunch Costs

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 0.5s
Memory limit: 1G

Problem type

Catering is expensive! Workplace team knows exactly how many people will come into the office on each of the next n days. However, the catering service, for consistency purposes, requires that workplace team order the same amount of food for each of those days.

Catering costs c dollars per person per day. It costs p dollars to feed a single person pizza on a day where insufficient catering is ordered. It is not possible to order catering or pizza for a fraction of a person - either a person eats entirely via catering for the day or via pizza ordered during that day.

Compute the minimum amount of money that workplace team needs to spend to feed everyone for the next n days.

Constraints

1 \le n \le 50

1 \le c, p \le 10^5

1 \le d_i \le 10^9

Subtask 1 [1 point]

1 \le d_i \le 10^3

Subtask 2 [1 point]

No additional constraints.

Input Specification

The first line contains three integers, n, c, and p.

The next line contains n integers. The i^\texttt{th} integer, d_i, is the number of people who will be in the office on day i.

Output Specification

Output the minimum cost in dollars that workplace team will need to spend.

Sample Input 1

2 1 100
10 20

Sample Output 1

40

Sample Explanation 1

If workplace team orders catering for 20 people, then it will cost 20 dollars every day, or 40 dollars in total.

Sample Input 2

2 1 1
10 20

Sample Output 2

30

Sample Explanation 2

If workplace team orders no catering and just buys pizza every day, then it will only cost 30 dollars.

Sample Input 3

1 100000 100000
1000000000

Sample Output 3

100000000000000

Comments

There are no comments at the moment.