Problem :

https://www.hackerrank.com/challenges/greedy-florist/problem


My Solution :

#!/usr/bin/python3


def getMinimumCost(k, c):
    cost = 0
    c.sort(reverse=True)
    for i in range(len(c)):
        cost += ((i // k) + 1) * c[i]
    return cost


n, k = map(int, input().split())
c = list(map(int, input().rstrip().split()))
minimumCost = getMinimumCost(k, c)
print(minimumCost)