기출 문제 / 삼성 2018 First Half Afternoon Problem 2

Minimizing Hospital Distance

You are given a city of size n×n consisting of people, hospitals, or empty spaces. The hospital distance for each person is defined as the distance to the nearest hospital, where the distance between two grid points (x1,y1) and (x2,y2) is defined as ∣x2−x1∣+∣y2−y1∣.