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