#Problem
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
#Think
- a.sort(reverse= True)
#Code
T = int(input())
# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다.
for test_case in range(1, T + 1):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
total = 0
for i in range(0, k):
total += a[i]
print(f"#{test_case} {total}")
'SWEA' 카테고리의 다른 글
[SWEA] 4299. 태혁이의 사랑은 타이밍(Python) (0) | 2024.11.11 |
---|---|
[SWEA] 9700. USB 꽂기의 미스터리 (Python) (0) | 2024.11.11 |
[SWEA] 3456. 직사각형 길이 찾기 (Python) (0) | 2024.11.11 |
[SWEA] 9997. 미니멀리즘 시계 (Python) (0) | 2024.11.11 |
[SWEA] 3314. 보충학습과 평균 (Python) (0) | 2024.11.11 |