n, k = map(int, input().split())
times = []
for i in range(n):
times.append(int(input()))
def solve(n, k, times):
assert len(times) == n
if n == 0:
return 0
if n == 1:
assert k >= 1
return 1
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
solve(n, k, times)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
2764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
2764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
2764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |