[20260110] BOJ / G1 / 소 운전한다. / 한종욱 #1783
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/19701
🧭 풀이 시간
120분
👀 체감 난이도
✏️ 문제 설명
소가 운전을 하는데, 고속도로에서 파는 돈까스를 먹고 가려고 한다. 1번 도시에서 각 도시까지 가는 고속도로들의 가중치 합에 그 중 한 고속도로에서 돈까스를 먹을 때의 가중치를 뺀 값의 최솟값을 구하라.
🔍 풀이 방법
1번 풀이
다익스트라인데 cost를 $가중치-맛%으로 놓고 풀었다. 이건 그리디한 방식이다. 앞에 적당한 돈까스가 나오고 뒤에 더 맛있는 돈까스가 나오면 그걸 체크할 수 없다.
2번 풀이
dist배열을 2차원으로 놓는다.dist[i][0]: i번째에서 돈까스를 먹지 않는다.dist[i][1]: i번째에서 돈까스를 먹는다.로 놓고 풀면 된다.
⏳ 회고
다익스트라를 오랜만에 푸느라 한참 헤맸다.