# 문제
https://school.programmers.co.kr/learn/courses/30/lessons/135808
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
# 문제 설명

# 정답 코드
def solution(k, m, score):
score = sorted(score, reverse=True)
sub = []
answer, cnt = 0,0
for i in score:
sub.append(i)
cnt += 1
if cnt == m:
answer += min(sub) * m
sub = []
cnt = 0
return answer
solution(4, 3, [4, 1, 2, 2, 4, 4, 4, 4, 1, 2, 4, 2])
# 핵심 개념
원래 매개변수 리스트 score
중간점검 변수 sub, cnt
최종정답 answer
총 4개를 사용했었다
'Algorithm🐤 > Python' 카테고리의 다른 글
| [프로그래머스] 기사단원의 무기 - 제곱근 시간복잡도 적게 구하기 (1) | 2024.06.10 |
|---|---|
| [프로그래머스] 모의고사 - [i % len(arr1)] (0) | 2024.06.06 |
| [프로그래머스] 카드 뭉치 - for 리스트, len, pop (0) | 2024.06.04 |
| [프로그래머스] 콜라 문제 - while 반복조건: ✔️ (0) | 2024.05.08 |
| [프로그래머스] 가장 가까운 같은 글자 - 딕셔너리에 값 추가/수정하기, 문자열.rfind()✔️ (0) | 2024.05.07 |