[이코테] 그리디 3-2. 큰수의 법칙

HJW·2022년 8월 25일
0
N, M, K = map(int, input().split())
Array = list(map(int, input().split()))

Array.sort()
first = Array[N-1]
secound = Array[N-2]

count = 0       # 큰 수의 법칙에 따른 결과

while True:
    for _ in range(K):
        count += first
        if M == 0:
            break
        M -= 1

    if M == 0:
        break

    count += secound
    M -= 1

print(count)
profile
be passionate

0개의 댓글