๐Ÿ ํŒŒ์ด์ฌ ์ƒ์ดˆ์งœ

[BOJ][Python] ๋ฐฑ์ค€ 7568๋ฒˆ: ๋ฉ์น˜

์„ ๋‹ฌ 2024. 11. 15. 06:10
๋ฐ˜์‘ํ˜•


https://www.acmicpc.net/problem/7568

 

๋ฌธ์ œ

์šฐ๋ฆฌ๋Š” ์‚ฌ๋žŒ์˜ ๋ฉ์น˜๋ฅผ ํ‚ค์™€ ๋ชธ๋ฌด๊ฒŒ, ์ด ๋‘ ๊ฐœ์˜ ๊ฐ’์œผ๋กœ ํ‘œํ˜„ํ•˜์—ฌ ๊ทธ ๋“ฑ์ˆ˜๋ฅผ ๋งค๊ฒจ๋ณด๋ ค๊ณ  ํ•œ๋‹ค.

์–ด๋–ค ์‚ฌ๋žŒ์˜ ๋ชธ๋ฌด๊ฒŒ๊ฐ€ x kg์ด๊ณ  ํ‚ค๊ฐ€ y cm๋ผ๋ฉด ์ด ์‚ฌ๋žŒ์˜ ๋ฉ์น˜๋Š” (x, y)๋กœ ํ‘œ์‹œ๋œ๋‹ค.

๋‘ ์‚ฌ๋žŒ A ์™€ B์˜ ๋ฉ์น˜๊ฐ€ ๊ฐ๊ฐ (x, y), (p, q)๋ผ๊ณ  ํ•  ๋•Œ x > p ๊ทธ๋ฆฌ๊ณ  y > q ์ด๋ผ๋ฉด ์šฐ๋ฆฌ๋Š” A์˜ ๋ฉ์น˜๊ฐ€ B์˜ ๋ฉ์น˜๋ณด๋‹ค "๋” ํฌ๋‹ค"๊ณ  ๋งํ•œ๋‹ค.  ์„œ๋กœ ๋‹ค๋ฅธ ๋ฉ์น˜๋ผ๋ฆฌ ํฌ๊ธฐ๋ฅผ ์ •ํ•  ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋‹ค.

์—ฌ๋Ÿฌ๋ถ„์€ ํ•™์ƒ N๋ช…์˜ ๋ชธ๋ฌด๊ฒŒ์™€ ํ‚ค๊ฐ€ ๋‹ด๊ธด ์ž…๋ ฅ์„ ์ฝ์–ด์„œ ๊ฐ ์‚ฌ๋žŒ์˜ ๋ฉ์น˜ ๋“ฑ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜์—ฌ ์ถœ๋ ฅํ•ด์•ผ ํ•œ๋‹ค.

์ž…๋ ฅ

์ฒซ ์ค„์—๋Š” ์ „์ฒด ์‚ฌ๋žŒ์˜ ์ˆ˜ N์ด ์ฃผ์–ด์ง„๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์ด์–ด์ง€๋Š” N๊ฐœ์˜ ์ค„์—๋Š” ๊ฐ ์‚ฌ๋žŒ์˜ ๋ชธ๋ฌด๊ฒŒ์™€ ํ‚ค๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์–‘์˜ ์ •์ˆ˜ x์™€ y๊ฐ€ ํ•˜๋‚˜์˜ ๊ณต๋ฐฑ์„ ๋‘๊ณ  ๊ฐ๊ฐ ๋‚˜ํƒ€๋‚œ๋‹ค.

์ถœ๋ ฅ

์—ฌ๋Ÿฌ๋ถ„์€ ์ž…๋ ฅ์— ๋‚˜์—ด๋œ ์‚ฌ๋žŒ์˜ ๋ฉ์น˜ ๋“ฑ์ˆ˜๋ฅผ ๊ตฌํ•ด์„œ ๊ทธ ์ˆœ์„œ๋Œ€๋กœ ์ฒซ ์ค„์— ์ถœ๋ ฅํ•ด์•ผ ํ•œ๋‹ค.

๋‹จ, ๊ฐ ๋ฉ์น˜ ๋“ฑ์ˆ˜๋Š” ๊ณต๋ฐฑ๋ฌธ์ž๋กœ ๋ถ„๋ฆฌ๋˜์–ด์•ผ ํ•œ๋‹ค.

 

 

ํ’€์ด

# input
n = int(input())
infos = [];
for i in range(n):
    weight, height = map(int, input().split())
    infos.append((weight, height))

# solution
ranks = [];
for weight,height in infos:
    bigger = 0
    for w,h in infos:
        if w>weight and h>height:
            bigger += 1
    ranks.append(bigger+1)

# output
for rank in ranks:
    print(rank)

 

 

๋ฐ˜์‘ํ˜•