<jupyter_start><jupyter_text>Greedy Florist![image](https://user-images.githubusercontent.com/50367487/83008342-fc102b00-a04f-11ea-952d-82fde5120592.png)<jupyter_code>#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the getMinimumCost function below.
def getMinimumCost(k, c):

    c.sort(reverse=True)

    res = 0
    for i in range(n):
        res += c[i] * (i // k + 1)

    return res

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    nk = input().split()

    n = int(nk[0])

    k = int(nk[1])

    c = list(map(int, input().rstrip().split()))

    minimumCost = getMinimumCost(k, c)

    fptr.write(str(minimumCost) + '\n')

    fptr.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15951742627345844, 'fraction_numerical': 0.05630026809651475, 'mean_word_length': 3.5548780487804876, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '605966', 'license': 'MIT', 'n_tokens_mistral': 328, 'n_tokens_neox': 284, 'n_words': 55, 'path': 'Interview Preparation Kit/6. Greedy Algorithms/Greedy Florist.ipynb', 'repo_name': 'Nam-SH/HackerRank', 'size': '746'}