From cefc086b08bfa6a6d31e8b7083ff96b491fb215f Mon Sep 17 00:00:00 2001 From: sm4640 Date: Tue, 20 Jan 2026 16:03:22 +0900 Subject: [PATCH] =?UTF-8?q?8979-s5.py=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workbook_8708/8979-s5.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 workbook_8708/8979-s5.py diff --git a/workbook_8708/8979-s5.py b/workbook_8708/8979-s5.py new file mode 100644 index 0000000..121a4a5 --- /dev/null +++ b/workbook_8708/8979-s5.py @@ -0,0 +1,35 @@ +# 올림픽 + +import sys + +input = sys.stdin.readline + +def solution(): + n, k = map(int, input().rstrip().split()) + records = [0] * n + for _ in range(n): + a, b, c, d = map(int, input().rstrip().split()) + records[a-1] = (b,c,d) + + ordered_records = sorted(records, key=lambda x:(-x[0], -x[1], -x[2])) + target = records[k-1] + rank = 0 + while 1: + now = (ordered_records[rank][0], ordered_records[rank][1], ordered_records[rank][2]) + if now == target: + break + rank += 1 + + print(rank+1) + return + +solution() + +""" +걸린 시간: 40분(dictionary 써서 더 좋게 해보려다가 늦음..) + +시간 복잡도: nlogn(정렬) + kn(기록, 탐색) => O(nlogn) + +해설: k를 인덱스에 맞춰서 records에 메달만 튜플로 넣는다. +records를 메달 규칙에 맞게 정렬 후 while로 타켓 튜플을 처음 찾고 +1 하면 그것이 그 그룹의 등수이다. +""" \ No newline at end of file