n, k = map(int, input().split())
times = []
for i in range(n):
l.append(int(input()))
def solve(n, k, times):
assert len(times) == n
if n <= 1:
return 0
total_visit_duration = times[-1] + 1 - times[0]
breaks = []
for i in range(n-1):
break_time = times[i+1] - (times[i] + 1)
if break_time > 0:
breaks.append(break_time)
breaks = sorted(breaks, reverse=True)
off_time = sum(breaks[:k-1])
return total_visit_duration - off_time
print(solve(n, k, times))
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
2764 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
2764 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
2764 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |