728x90
SW Expert Academy
SW ํ๋ก๊ทธ๋๋ฐ ์ญ๋ ๊ฐํ์ ๋์์ด ๋๋ ๋ค์ํ ํ์ต ์ปจํ ์ธ ๋ฅผ ํ์ธํ์ธ์!
swexpertacademy.com
์ค๋ช
๊ฐ ๊ณผ๋ชฉ์ ์ ์๋ ์ ์, ๋ง์ ์ 100์ ์ด๋ค.
์ฑ์ ํ์๋ ์ด ์ค์์ ์ ํํ K๊ฐ์ ๊ณผ๋ชฉ์ ์ ํํ์ฌ ๋ฃ์ ์ ์๋ค. ์ฑ์ ํ์ ๋ํ๋๋ ์ด์ ์ด ๊ฐ์ฅ ํฌ๋๋ก ์ฑ์ ํ๋ฅผ ๋ง๋ค์ด์ผ ํ๋ค. ์ต๋๋ก ๋ง๋ค ์ ์๋ ์ด์ ์ ๋ช์ ์ธ์ง ๊ตฌํด๋ผ.
ํ์ด
๋ฆฌ์คํธ๋ฅผ ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ ํ ๋ฐ๋ณต๋ฌธ์ผ๋ก k๋งํผ ๊ฒฐ๊ณผ๊ฐ์ ๋ฃ์ด์ค๋ค.
Solution
t = int(input())
for tc in range(1, t+1):
n, k = map(int, input().split())
score = list(map(int, input().split()))
ans = 0
score.sort(reverse=True)
for i in range(k):
ans += score.pop(0) #ans += score[i] ๋ ๊ฐ๋ฅํ๋ popํด์ฃผ๋ ๊ฒ ์๊ฐ์ ์กฐ๊ธ ๋น ๋ฆ
print('#'+str(tc), ans)728x90
'๐งฉ Algorithm > SWEA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [SWEA] 21425. += (Python/D2) (0) | 2024.10.16 |
|---|---|
| [SWEA] 5162. ๋๊ฐ์ง ๋นต์ ๋๋ ๋ง (Python/D2) (2) | 2023.11.19 |
| [SWEA] 2007. ํจํด ๋ง๋์ ๊ธธ์ด (Python/D2) (0) | 2023.11.19 |
| [SWEA] 1208. [S/W ๋ฌธ์ ํด๊ฒฐ ๊ธฐ๋ณธ] 1์ผ์ฐจ - Flatten (Python/D3) (0) | 2023.11.19 |
| [SWEA] 1206. [S/W ๋ฌธ์ ํด๊ฒฐ ๊ธฐ๋ณธ] 1์ผ์ฐจ - View (Python/D3) (0) | 2023.11.16 |