[Week03] BOJ: 휴게소 세우기 #31
Open
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.
문제 정보
풀이 방법
간단히 어떤 방식으로 풀었는지 설명해주세요.
1try
그리디: 가장 긴 휴게소 간 길이를 찾아 그 중간 지점에 휴게소 설치, 이 과정을$M$ 번 반복$M=2, L=100$ , 그리디한 방법은 최대 길이가 50이나, 실제로는 3등분한 경우(최대 길이 34)가 최적해임.
문제점: 최적해를 보장하지 않음 (반례:
2try
매개변수 탐색:
mid를 휴게소 간 최대 길이로 설정,mid길이일 때 설치한 휴게소 수가 적으면left조정, 그렇지 않으면right조정시간복잡도:$O(NlogN+NlogL)$ : 벡터 정렬, 이분 탐색에서 $O(N)$
chk메서드 수행공간복잡도:
체크리스트
{닉네임}.{확장자})추가 코멘트
(선택사항) 추가로 공유하고 싶은 내용이 있다면 작성해주세요.