[20251008] BOJ / P5 / 전투기 출격 / 권혁준 #1071
Merged
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/27116
🧭 풀이 시간
45분
👀 체감 난이도
✏️ 문제 설명
M개의 구역이 존재하고, i번 구역에서 j번 구역으로 가는 거리는 d[i][j]이고, 이동할 때는 이만큼의 연료를 소모한다.
i번 구역에 착륙할 때는 f[i]만큼의 연료를 소모한다.
1번 구역에서 출발하여 길이 N인 비행경로를 순서대로 순회하되, 하나의 구역에 착륙한 뒤 다시 이륙해서 순회해야 한다.
착륙한 구역의 다음 구역부터 연속한 몇 개의 구역을 동료에게 대신 순회하게 할 수 있다.
동료가 순회하는 구역의 최소 개수와 그때 사용하는 연료의 최솟값을 구해주자.
🔍 풀이 방법
비행 경로의 어떤 지점 i에서 착륙할 때,
동료 조종사가 순회하는 구역 수를 x로 두고 그 때 소모하는 연료를 f(x)로 두면
f(x)는 감소함수임.
-> 이분 탐색으로 x를 찾을 수 있음.
한 스텝에 드는 시간복잡도가 상수면 전체는 O(NlogN)으로 가능
⏳ 회고
구현이 좀 힘들었다