CodeTON Round 8 (Div. 1 + Div. 2, Rated, Prizes!) C2. Bessie’s Birthday Cake (Hard Version)
3139. Minimum Cost to Equalize Array
You are given an integer array
numsand two integerscost1andcost2. You are allowed to perform either of the following operations any number of times:
- Choose an index
ifromnumsand increasenums[i]by1for a cost ofcost1.- Choose two different indices
i,j, fromnumsand increasenums[i]andnums[j]by1for a cost ofcost2.Return the minimum cost required to make all elements in the array equal*.*
Since the answer may be very large, return it modulo
109 + 7.