Skip to content

Commit

Permalink
2024-02-17
Browse files Browse the repository at this point in the history
.
  • Loading branch information
Hwangyerin committed Feb 17, 2024
1 parent ea235f7 commit fb178c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Hwangyerin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
| 11차시 | 2024.02.01 | 수학 | <a href=https://www.acmicpc.net/problem/10870>피보나치 수 5</a> | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/47) |
| 12차시 | 2024.02.04 | 이분탐색 | <a href=https://www.acmicpc.net/problem/11478>서로 다른 부분 문자열의 개수</a> | [#51](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/51) |
| 13차시 | 2024.02.07 | 그리디 알고리즘 | <a href=https://www.acmicpc.net/problem/1789>수들의 합</a> | [#55](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/55) |
| 14차시 | 2024.02.15 | 그리디 알고리즘 | <a href=https://www.acmicpc.net/problem/1343>폴리오미노</a> | [#63](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/63) |
| 15차시 | 2024.02.17 | 그리디 알고리즘 | <a href=https://www.acmicpc.net/problem/1758>알바생 강호</a> | [#68](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/68) |
11 changes: 11 additions & 0 deletions Hwangyerin/그리디 알고리즘/알바생 강호.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def hap_tips(tip_list):
tip_list.sort(reverse=True) #내림차순으로 정렬
total_tip = 0
for i, tip in enumerate(tip_list):
total_tip += max(tip - i, 0) #팁에서 순서값을 뺀 값 중에 양수인 것만 누적 합
return total_tip

n = int(input()) #스타박스 앞에 서 있는 사람의 수 N
tip_list = [int(input()) for _ in range(n)] #총 N개의 줄에 각 사람이 주려고 하는 팁 리스트

print(hap_tips(tip_list))

0 comments on commit fb178c6

Please sign in to comment.