From 528bb6617e8833de9a0de58163df407e2b6a7394 Mon Sep 17 00:00:00 2001 From: kjs254 <149364697+kjs254@users.noreply.github.com> Date: Thu, 22 Feb 2024 01:53:15 +0900 Subject: [PATCH] =?UTF-8?q?2024-02-21=20=EA=B5=AC=EB=AA=85=EB=B3=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kjs254/README.md | 2 ++ ...5\254\353\252\205\353\263\264\355\212\270.py" | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 "kjs254/\352\267\270\353\246\254\353\224\224/\352\265\254\353\252\205\353\263\264\355\212\270.py" 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