Skip to content

Commit

Permalink
[#1] 그리디 3-2
Browse files Browse the repository at this point in the history
  • Loading branch information
ezidayzi committed Dec 25, 2021
1 parent 8b63dfa commit a1514e7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions CodingTestBook/3-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 입력
n, m, k = map(int, input().split())
arr = list(map(int, input().split()))

# 정렬
arr.sort(reverse=True)

sum = 0

i = 0

while i < m:
if (i+1) % (k+1) == 0 and i != 0:
sum += arr[1]
i = i + 1
else:
z = 0
for z in range(k):
sum += arr[0]
i = i + 1

print(sum)

0 comments on commit a1514e7

Please sign in to comment.