์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ/BOJ_Python

[BOJ/Step9] 1085 : ์ง์‚ฌ๊ฐํ˜•์—์„œ ํƒˆ์ถœ (Python)

NaNaRin๐Ÿ™ƒ 2021. 2. 15. 18:37

www.acmicpc.net/problem/1085

 

1085๋ฒˆ: ์ง์‚ฌ๊ฐํ˜•์—์„œ ํƒˆ์ถœ

ํ•œ์ˆ˜๋Š” ์ง€๊ธˆ (x, y)์— ์žˆ๋‹ค. ์ง์‚ฌ๊ฐํ˜•์˜ ์™ผ์ชฝ ์•„๋ž˜ ๊ผญ์ง“์ ์€ (0, 0)์— ์žˆ๊ณ , ์˜ค๋ฅธ์ชฝ ์œ„ ๊ผญ์ง“์ ์€ (w, h)์— ์žˆ๋‹ค. ์ง์‚ฌ๊ฐํ˜•์˜ ๊ฒฝ๊ณ„์„ ๊นŒ์ง€ ๊ฐ€๋Š” ๊ฑฐ๋ฆฌ์˜ ์ตœ์†Ÿ๊ฐ’์„ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

www.acmicpc.net


 

1. ํ•œ์ˆ˜์˜ ์œ„์น˜๋กœ๋ถ€ํ„ฐ ๊ฒฝ๊ณ„์„ ๊นŒ์ง€ ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ฑฐ๋ฆฌ๋Š” x, w-x, y, h-y ์ค‘ ๊ฐ€์žฅ ์ž‘์€ ์ˆ˜ ์ด๋‹ค.

    => ๋‚ด์žฅํ•จ์ˆ˜ min() ์‚ฌ์šฉ

# 1085.py

x, y, w, h = map(int, input().split())

print(min(x, y, w - x, h - y))