-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
23-jung0115 #184
Open
jung0115
wants to merge
23
commits into
main
Choose a base branch
from
23-jung0115
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
23-jung0115 #184
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
➡️ 문제 풀이 코드
🔗 문제 링크
프로그래머스 | 그리디 알고리즘 - 구명보트(Lv.2)
✔️ 소요된 시간
25분
✨ 수도 코드
✅ 최종 코드
구명보트에 2명까지만 탈 수 있다는 게 핵심입니다!
처음에는 단순히 오름차순, 내림차순 중 하나로 정렬해서 한쪽으로 쭉 빼면 되겠다고 생각했는데,
이 경우 구명보트 개수가 최소가 되지 않았습니다
최소로 만들기 위해서는 가벼운 사람을 잘 이용해야 합니다!
가장 무거운 사람과 가벼운 사람을 짝지어서 한 보트에 태울 수 있는지 판단하고,
불가능하다면 무거운 사람 혼자 보냅니다
무거운 사람을 태운 배에 가벼운 사람을 끼워넣을 수 있는지(?)를 체크한다고 생각하면 편합니다!
이런식으로 반복하다가 마지막에 한 명만 남았다면 비교없이 바로 태우고 보내면 됩니다
📚 새롭게 알게된 내용
새롭게 알게된 내용은 아니지만... python으로 코테 준비할 일이 생겨서 해봤는데 python 오랜만에 쓰니 문법부터 헷갈리는 게 많네요 🥲