Merged
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/27370
🧭 풀이 시간
12분
👀 체감 난이도
✏️ 문제 설명
Albert는 친구 Bob과 함께 배달 아르바이트를 해보기로 했다.
특이하게도 두 곳의 물류창고 (A 와 B) 및 배달 목적지인$N$ 곳의 집들은 모두 1차원 직선상에 위치해있다. 편의상 두 물류 창고의 좌표를 $P_A$ , $P_B$ 라 하고 $i$ 번째 집의 좌표를 $X_i$ 라 하자.
각 목적지는 한 명만이 왕복해야할 때, 두 사람의 이동거리 총 합의 최솟값과, 그 때의 두 사람의 이동거리 차이의 최솟값을 구해보자.
🔍 풀이 방법
이동거리 총 합의 최소는 간단하다. 목적지마다, 더 가까운 사람에게 배정하면 된다.
이동거리 차이의 최소를 구하려면, A, B로부터 거리가 동일한 목적지들만 잘 배정해주면 된다.
⏳ 회고
이동거리의 차이니까 음수가 나오면 안되는데, 미처 생각못하고 두 번 틀렸다.