Skip to content

Commit

Permalink
Merge pull request #34 from AlgoLeadMe/9-wnsmir
Browse files Browse the repository at this point in the history
9-wnsmir
  • Loading branch information
wnsmir authored Dec 10, 2024
2 parents a35d051 + 9c3d730 commit 41b1744
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
N, M, K = map(int, input().split())

data = list(map(int, input().split()))

data.sort()

first = data[-1]
second = data[-2]

result = 0

while True:
for i in range(K):
if M == 0:
break
result += first

M -= 1

if M == 0:
break
result += second
M -= 1

print(result)

0 comments on commit 41b1744

Please sign in to comment.