프로그래밍/HackerRank
[HackerRank][Python3] Greedy Florist
snoopybox
2018. 7. 16. 00:44
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)