forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2.py
More file actions
18 lines (14 loc) ยท 602 Bytes
/
2.py
File metadata and controls
18 lines (14 loc) ยท 602 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# N, M, K๋ฅผ ๊ณต๋ฐฑ์ ๊ธฐ์ค์ผ๋ก ๊ตฌ๋ถํ์ฌ ์
๋ ฅ ๋ฐ๊ธฐ
n, m, k = map(int, input().split())
# N๊ฐ์ ์๋ฅผ ๊ณต๋ฐฑ์ ๊ธฐ์ค์ผ๋ก ๊ตฌ๋ถํ์ฌ ์
๋ ฅ ๋ฐ๊ธฐ
data = list(map(int, input().split()))
data.sort() # ์
๋ ฅ ๋ฐ์ ์๋ค ์ ๋ ฌํ๊ธฐ
first = data[n - 1] # ๊ฐ์ฅ ํฐ ์
second = data[n - 2] # ๋ ๋ฒ์งธ๋ก ํฐ ์
# ๊ฐ์ฅ ํฐ ์๊ฐ ๋ํด์ง๋ ํ์ ๊ณ์ฐ
count = int(m / (k + 1)) * k
count += m % (k + 1)
result = 0
result += (count) * first # ๊ฐ์ฅ ํฐ ์ ๋ํ๊ธฐ
result += (m - count) * second # ๋ ๋ฒ์งธ๋ก ํฐ ์ ๋ํ๊ธฐ
print(result) # ์ต์ข
๋ต์ ์ถ๋ ฅ