[20251107] BOJ / G3 / 수상 택시 / 이준희 #1337
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/2836
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
0번집에 사는 상근이가 M번 집까지 가는 길에 중간에 사는 사람들을 모두 데려다 주려고 할 때
상근이가 움직여야 하는 거리의 최솟값을 구하는 문제입니다.
🔍 풀이 방법
어차피 M번집까지 가야하기 때문에 정방향으로 가는 경우는 고려하지 않아도 됐었습니다.
그래서 역방향으로 가는 경우만 찾아서 배열에 넣은 후
겹치는 구간을 구해서 총 역방향 이동거리를 구했습니다.
역방향 이동거리만큼 다시 정방향으로 이동해야하기 때문에 M + (역방향이동*2) 로 구했습니다.
⏳ 회고
얼마전에 풀었던 아우어아 어쩌구랑 비슷했습니다.