⭐ 문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/135808
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
⭐ 풀이 코드
❌ 시간초과
def solution(k, m, score):
answer = 0
score.sort(reverse=True)
for i in range(len(score)):
temp = 0
if (i+1)%m == 0:
box = score[temp:i+1]
temp = i+1
answer += (min(box)*m)
return answer
⭕ 통과
def solution(k, m, score):
answer = 0
score.sort(reverse=True)
for i in range(len(score)):
if (i+1)%m == 1:
box = []
box.append(score[i])
if (i+1)%m == 0:
answer += (min(box)*m)
return answer
'Python > Programmers' 카테고리의 다른 글
[프로그래머스/Python] Lv 2. [3차] 압축 (0) | 2023.04.16 |
---|---|
[프로그래머스/Python] Lv 1. 추억 점수 (0) | 2023.04.16 |
[프로그래머스/Python] Lv 1. 명예의 전당 (1) (0) | 2023.04.16 |
[프로그래머스/Python] Lv 2. 2 x n 타일링 (0) | 2023.04.15 |
[프로그래머스/Python] Lv 2. 방문길이 (0) | 2023.04.15 |