Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21-H0ngJu #208

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@
| 18μ°¨μ‹œ | 2024.05.26 | DFS | [κ³„λž€μœΌλ‘œ κ³„λž€μΉ˜κΈ°](https://www.acmicpc.net/problem/16987) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/199 |
| 19μ°¨μ‹œ | 2024.05.31 | DP | [ν•©λΆ„ν•΄](https://www.acmicpc.net/problem/2225) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/202 |

| 21μ°¨μ‹œ | 2024.06.07 | 그리디 | [행볡 μœ μΉ˜μ›](https://www.acmicpc.net/problem/13164) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/208 |

---
19 changes: 19 additions & 0 deletions H0ngJu/그리디/행볡 μœ μΉ˜μ›.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys

def input(): return sys.stdin.readline().rstrip()

N, K = map(int, input().split())
data = list(map(int, input().split()))
diff = [0] * N

for i in range(N-1):
diff[i] = data[i+1] - data[i]

diff.sort(reverse=True)

total_diff = sum(diff)

for i in range(K-1):
total_diff -= diff[i]
Comment on lines +12 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와 κ·Έλƒ₯ diff둜만 해도 λ˜λ„€μš”... κ°œλ˜‘λ˜‘..


print(total_diff)
Loading