Greedy Florist

  • + 0 comments

    Python

    def getMinimumCost(k, c):
        n_flowers = len(c)
        c = sorted(c, reverse=True)
        price = 0
        count = 0
        for i in range(n_flowers):
            if i % k ==0 and i != 0 :
                count += 1
            price += c[i] * (count + 1)
            # print(price)
        return price