-
python3 Get minimum value with multiple criteria아무거나적어~ 2022. 9. 29. 15:12123456789101112from functools import cmp_to_keydef left_low(l, r):if l[1] == r[1]:return l[0] - r[0]else:return l[1] - r[1]n = int(input())d = [tuple(map(int, input().split())) for _ in range(n)]cri = min(d, key=cmp_to_key(left_low))print(cri)cs
min 은 빈 리스트가 들어오면 에러를 일으키기 때문에 default 를 사용하기도 합니다.
1'아무거나적어~' 카테고리의 다른 글
gksrmfdl dkscuwudy (0) 2022.10.09 remind parametric search (0) 2022.09.30 definition of lower_bound and upper_bound (0) 2022.09.27 선분교차 (0) 2022.09.26 python3 customized compare function (0) 2022.09.24