
백준 문제집 PS
ses0028님의 "IT기업 및 대기업 계열사 코테보면서 비슷했던 문제들(지속적으로 업데이트 중)"
이번 방학 2달동안 골드 3 (81문제)까지 다 푸는 것이 목표입니다.
25.01.13 - 실버 4 1문제
⛳ (17/81문제)
문제 문제 제목 문제 티어 문제 링크 1205 등수 구하기 실버 4 https://www.acmicpc.net/problem/1205

20분
실버 4

input = open(0).readline
N, t_score, P = map(int, input().split())
if N == 0:
print(1)
exit()
else:
scores = sorted(list(map(int, input().split())), reverse=True)
if t_score in scores:
for i in range(N):
if scores[i] < t_score:
print(scores.index(t_score) + 1)
exit()
elif i == N-1 and scores[N-1] == t_score:
if N >= P:
print(-1)
else:
print(scores.index(t_score) + 1)
exit()
else:
for i in range(N):
if scores[i] < t_score and i <= P:
print(i+1)
exit()
if N < P:
print(N+1)
exit()
print(-1)
N: 리스트에 있는 점수의 개수
t_score: 태수의 새로운 점수
P: 랭킹 리스트에 올라갈 수 있는 점수의 개수
scores: 내림차순으로 정렬된 점수들 리스트
반례들을 모두 고려해서 코드를 작성하자.