diff --git a/kjs254/README.md b/kjs254/README.md index 620af80..4f94749 100644 --- a/kjs254/README.md +++ b/kjs254/README.md @@ -5,4 +5,6 @@ | 1차시 | 2024.02.12 | 스택 | [기능개발](https://school.programmers.co.kr/learn/courses/30/lessons/42586) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/2) | | 2차시 | 2024.02.15 | 큐 | [프로세스](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/6) | | 3차시 | 2024.02.15 | 힙 | [야근 지수](https://school.programmers.co.kr/learn/courses/30/lessons/12927) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/10) | +| 4차시 | 2024.02.15 | 그리디 | [구명보트](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#13](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/13) | + --- diff --git "a/kjs254/\352\267\270\353\246\254\353\224\224/\352\265\254\353\252\205\353\263\264\355\212\270.py" "b/kjs254/\352\267\270\353\246\254\353\224\224/\352\265\254\353\252\205\353\263\264\355\212\270.py" new file mode 100644 index 0000000..4e9f3ff --- /dev/null +++ "b/kjs254/\352\267\270\353\246\254\353\224\224/\352\265\254\353\252\205\353\263\264\355\212\270.py" @@ -0,0 +1,16 @@ +from collections import deque + +def solution(people, limit): + answer = 0 + people = deque(sorted(people)) + + while len(people)>1: + if people[0]+people[-1]<=limit: + people.pop() + people.popleft() + answer+=1 + else: + people.pop() + answer+=1 + + return answer+1 if people else answer \ No newline at end of file