rueki
BOJ 1758. 알바생 강호 본문
728x90
반응형
https://www.acmicpc.net/problem/1758
1. 최대로 돈 많이 갖고 있는 사람이 제일 먼저 받으면 팁 제일 많이 받을 수 있음
2. 내림차순 정렬 후 총 합 계산
n = int(input())
tip = [int(input()) for _ in range(n)]
tip.sort(reverse=True)
result = 0
for idx, t in enumerate(tip):
ri = idx + 1
real_tip = t - (ri - 1)
if real_tip > 0:
result += real_tip
else:
result += 0
print(result)
728x90
반응형
'python > 알고리즘 문제풀이' 카테고리의 다른 글
BOJ 1051. 숫자 정사각형 (0) | 2022.08.10 |
---|---|
BOJ 1331. 나이트 투어 (0) | 2022.08.07 |
LeetCode - 121. Best Time to Buy and Sell Stock (0) | 2020.08.31 |
SW Expert Academy 2001. 파리 퇴치 (0) | 2020.06.24 |
2005. 파스칼의 삼각형 (0) | 2020.06.20 |
Comments