정답
- 역순 슬라이싱 : score[-1 : -1-m : -1] 혹은 score[-m:], 첫번째는 데이터가 반대로 흘러가서 역방향으로 조회됨
- 리스트에서 해당 범위를 삭제 : del a[start:end]
def solution(k, m, score):
score.sort() # 오름차순 정렬
ans = 0
while len(score) >= m:
s = score[-m:]
del score[-m:]
ans = ans + s[0] * m
return ans
'Algorithm' 카테고리의 다른 글
소수 만들기 / 프로그래머스 (0) | 2025.03.01 |
---|---|
모의고사 / 프로그래머스 (0) | 2025.02.28 |
카드 뭉치 / 프로그래머스 (0) | 2025.02.24 |
2016년 / 프로그래머스 (0) | 2025.02.21 |
명예의 전당 (1) / 프로그래머스 (0) | 2025.02.17 |