실버 5 - 올림픽
내 코드
from sys import stdin
# N: 참여 나라 수
# K: 등수 구하고자 하는 나라
# arr[0] 국가 나타내는 숫자
# arr[1] 금
# arr[2] 은
# arr[3] 동
N, K = map(int, stdin.readline().split())
scores = []
target = []
for _ in range(N):
newScore = (list(map(int, stdin.readline().split())))
if newScore[0] == K:
target = newScore
else:
scores.append(newScore)
scores.sort(key=lambda x: (x[1], x[2], x[3]), reverse=True)
win = []
lose = []
for idx in range(1, 4):
for s in scores:
if idx >= 2:
if s not in win and s not in lose and s[idx] > target[idx]:
win.append(s)
elif s not in win and s not in lose and s[idx] < target[idx]:
lose.append(s)
else:
if s[idx] > target[idx]:
win.append(s)
elif s[idx] < target[idx]:
lose.append(s)
for w in win:
if w in scores:
scores.remove(w)
if len(lose) > 0:
for l in lose:
if l in scores:
scores.remove(l)
print(len(win) +1)
728x90
'Algorithm&CodingTest > Baekjoon' 카테고리의 다른 글
[Baekjoon] [20125] 실버4 - 쿠키의 신체 측정 Python (0) | 2024.01.23 |
---|---|
[Baekjoon] [25757] 실버5 - 임스와 함께하는 미니게임 Python (1) | 2024.01.23 |
[Baekjoon][7568] 실버5 - 덩치 Python (0) | 2024.01.19 |
[Baekjoon][1495] 실버1 - 기타리스트 (0) | 2023.04.22 |
[Beakjoon] [1271] 브론즈 5 - 엄청난 부자2 (0) | 2023.03.17 |