Merged
Conversation
This file contains hidden or 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.
🧷 문제 링크
https://www.acmicpc.net/problem/1263
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
수행해야 할 일들의 걸리는 시간, 마감 기한이 주어졌을 때
일을 모두 마칠 수 있는 가장 늦은 시간을 출력하는 문제입니다.
문제가 다소 애매하게 써있어서 예제를 보고 파악했어야 했습니다.
일을 모두 마칠 수 있는 가장 늦은 시간이란?
일을 모두 마칠 수 있는 선에서 가장 늦게 시작해도 되는 시간 이라는 뜻 입니다.
🔍 풀이 방법
그리디를 이용해서 풀었습니다.
job 자료구조를 만들어서 걸리는 시간, 마감 기한을 설정해놓고
마감 기한 역순으로 정렬한 후 풀었습니다.
가장 마지막에 끝나도 되는 일을 기준으로 걸리는 시간만큼 빼서
가장 늦게 시작해도 되는 시간을 구했습니다.
이 때 전부 계산했을 때 음수가 나온다면 -1을 출력하여 못하는 경우를 처리했습니다.
⏳ 회고
뭔가 그리디는 풀면 풀리는데 머리로는 이해가 안되는 경우가 조금 있어서
매번 풀 때 마다 헷갈리는 것 같습니다.