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/15553
🧭 풀이 시간
12분
👀 체감 난이도
✏️ 문제 설명
구사과의 방에는 난로가 하나 있고, 방에 친구가 왔을 때는 항상 난로를 켠다.
오늘은 N명의 친구들이 구사과의 집에 방문하는 날이다.
i번째 친구는 구사과의 방에 시간 T[i]에 도착하고, 시간 T[i]+1에 나간다.
처음에 난로는 꺼져있고, 난로를 최대 K번 켤 수 있다.
구사과는 난로가 켜져 있는 시간을 최소로 하려고 한다.
🔍 풀이 방법
[사용한 알고리즘]
처음에 그냥 난로를 N번 다 켜놓고, 켜는 걸 취소했을 때 발생하는 비용이 적은 순서대로 꺼주면 된다.
⏳ 회고
로직을 잘못 짜서 한 번 갈아엎었다...