[BOJ] 20949 효정과 새 모니터
Post
취소

[BOJ] 20949 효정과 새 모니터

문제 요약 및 풀이

20949번: 효정과 새 모니터

sqrt를 하든 안하든, 문제 상에 주어지는 77인치로 나누든 안 나누든

\(w*w + h*h\) 의 대소만 비교해서 정렬하면 된다.

풀이 코드

1
2
3
4
5
6
7
8
9
L = []

for i in range(int(input())):
  w,h = map(int, input().split())
  L.append([w*w+h*h, i])

for i in sorted(L, key = lambda t : (-t[0], t[1])):
  print(i[1] + 1)

This post is licensed under CC BY 4.0 by the author.