📌문제
https://programmers.co.kr/learn/courses/30/lessons/42885
🎖️난이도
Level 2
✔️풀이
# sol
def solution(people, limit):
people.sort()
cnt = 0
l = len(people)
tmp_limit = limit
p = 0 # 타고 있는 사람 수 (최대 2명)
for i in range(l):
tmp_person = people[i]
if tmp_limit >= tmp_person and p < 2:
tmp_limit -= tmp_person
p += 1
continue
cnt += 1
tmp_limit = limit - tmp_person
p = 1
return cnt + 1
'[ 알고리즘 ] > Greedy' 카테고리의 다른 글
[백준] 11399. ATM (0) | 2022.06.30 |
---|---|
[프로그래머스] 단속카메라 (0) | 2022.06.29 |
[프로그래머스] 큰 수 만들기 (0) | 2022.06.29 |
[프로그래머스] 체육복 (0) | 2022.06.29 |
[백준] 11501. 주식 (0) | 2022.06.29 |