Skip to content

Commit

Permalink
2024-06-07
Browse files Browse the repository at this point in the history
  • Loading branch information
H0ngJu committed Jun 7, 2024
1 parent 5aee288 commit 5c2c546
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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 |

---
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]

print(total_diff)

0 comments on commit 5c2c546

Please sign in to comment.