Skip to content

Commit

Permalink
9-wnsmir
Browse files Browse the repository at this point in the history
  • Loading branch information
wnsmir committed Nov 26, 2024
1 parent 0dc3905 commit 9c3d730
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 9c3d730

Please sign in to comment.