Skip to content

Commit 0afeccd

Browse files
committed
[Bronze III] Title: 직사각형에서 탈출, Time: 4 ms, Memory: 69104 KB -BaekjoonHub
1 parent 1649810 commit 0afeccd

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# [Bronze III] 직사각형에서 탈출 - 1085
2+
3+
[문제 링크](https://www.acmicpc.net/problem/1085)
4+
5+
### 성능 요약
6+
7+
메모리: 69104 KB, 시간: 4 ms
8+
9+
### 분류
10+
11+
기하학, 수학
12+
13+
### 제출 일자
14+
15+
2025년 4월 3일 23:15:00
16+
17+
### 문제 설명
18+
19+
<p>한수는 지금 (x, y)에 있다. 직사각형은 각 변이 좌표축에 평행하고, 왼쪽 아래 꼭짓점은 (0, 0), 오른쪽 위 꼭짓점은 (w, h)에 있다. 직사각형의 경계선까지 가는 거리의 최솟값을 구하는 프로그램을 작성하시오.</p>
20+
21+
### 입력
22+
23+
<p>첫째 줄에 x, y, w, h가 주어진다.</p>
24+
25+
### 출력
26+
27+
<p>첫째 줄에 문제의 정답을 출력한다.</p>
28+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
let xywh = readLine()!.split { $0 == " " }.map { Int(String($0))! },
2+
x = xywh[0],
3+
y = xywh[1],
4+
w = xywh[2],
5+
h = xywh[3]
6+
let minX = min(x - 0, w - x)
7+
let minY = min(y - 0, h - y)
8+
let minDist = min(minX, minY)
9+
print(minDist)

0 commit comments

Comments
 (0)