N, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
if K >= N:
print(N)
exit()
intervals = []
for i in range(1, N):
intervals.append(T[i] - T[i - 1] - 1)
intervals.sort()
total_time = N
for i in range(N - K):
total_time += intervals[i]
print(total_time)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
2908 KB |
Output is correct |
2 |
Correct |
8 ms |
2904 KB |
Output is correct |
3 |
Correct |
9 ms |
2920 KB |
Output is correct |
4 |
Correct |
12 ms |
2908 KB |
Output is correct |
5 |
Correct |
9 ms |
2976 KB |
Output is correct |
6 |
Correct |
9 ms |
2888 KB |
Output is correct |
7 |
Correct |
8 ms |
2984 KB |
Output is correct |
8 |
Correct |
8 ms |
2768 KB |
Output is correct |
9 |
Correct |
8 ms |
2976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
2908 KB |
Output is correct |
2 |
Correct |
8 ms |
2904 KB |
Output is correct |
3 |
Correct |
9 ms |
2920 KB |
Output is correct |
4 |
Correct |
12 ms |
2908 KB |
Output is correct |
5 |
Correct |
9 ms |
2976 KB |
Output is correct |
6 |
Correct |
9 ms |
2888 KB |
Output is correct |
7 |
Correct |
8 ms |
2984 KB |
Output is correct |
8 |
Correct |
8 ms |
2768 KB |
Output is correct |
9 |
Correct |
8 ms |
2976 KB |
Output is correct |
10 |
Correct |
11 ms |
3164 KB |
Output is correct |
11 |
Correct |
11 ms |
3204 KB |
Output is correct |
12 |
Correct |
15 ms |
3164 KB |
Output is correct |
13 |
Correct |
11 ms |
3164 KB |
Output is correct |
14 |
Correct |
11 ms |
3248 KB |
Output is correct |
15 |
Correct |
11 ms |
3164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
2908 KB |
Output is correct |
2 |
Correct |
8 ms |
2904 KB |
Output is correct |
3 |
Correct |
9 ms |
2920 KB |
Output is correct |
4 |
Correct |
12 ms |
2908 KB |
Output is correct |
5 |
Correct |
9 ms |
2976 KB |
Output is correct |
6 |
Correct |
9 ms |
2888 KB |
Output is correct |
7 |
Correct |
8 ms |
2984 KB |
Output is correct |
8 |
Correct |
8 ms |
2768 KB |
Output is correct |
9 |
Correct |
8 ms |
2976 KB |
Output is correct |
10 |
Correct |
11 ms |
3164 KB |
Output is correct |
11 |
Correct |
11 ms |
3204 KB |
Output is correct |
12 |
Correct |
15 ms |
3164 KB |
Output is correct |
13 |
Correct |
11 ms |
3164 KB |
Output is correct |
14 |
Correct |
11 ms |
3248 KB |
Output is correct |
15 |
Correct |
11 ms |
3164 KB |
Output is correct |
16 |
Correct |
104 ms |
12156 KB |
Output is correct |
17 |
Correct |
124 ms |
12144 KB |
Output is correct |
18 |
Correct |
107 ms |
12136 KB |
Output is correct |
19 |
Correct |
103 ms |
12124 KB |
Output is correct |
20 |
Correct |
101 ms |
12140 KB |
Output is correct |
21 |
Correct |
100 ms |
12144 KB |
Output is correct |
22 |
Correct |
97 ms |
12140 KB |
Output is correct |
23 |
Correct |
96 ms |
12144 KB |
Output is correct |
24 |
Correct |
95 ms |
12136 KB |
Output is correct |