- 각 사람이 주려고 하는 팁을 내림차순으로 정렬한 다음 반복문을 돌려 (각 사람이 주려고 생각하는 팁 - (받은 등수 - 1))만큼의 팁이 음수라면 팁을 주지 않고 0이상이라면 팁을 주는 방식으로 코드를 작성했다.
import sys
N = int(input())
customer = []
for _ in range(N):
customer.append(int(sys.stdin.readline().strip()))
customer.sort(reverse=True)
rank = 1
total = 0
for i in customer:
if i - (rank - 1) < 0:
continue
else:
total += i - (rank - 1)
rank += 1
print(total)