n, k = map(int, input().split())
g = [int(input()) for _ in range(n)]
res = []
for i in range(1, n):
res += [g[i] - g[i - 1]]
ans = 0
res.sort()
for i in range(n - k):
ans += res[i] - 1
print(ans + n)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
2764 KB |
Output is correct |
2 |
Correct |
15 ms |
2800 KB |
Output is correct |
3 |
Correct |
16 ms |
2764 KB |
Output is correct |
4 |
Correct |
16 ms |
2824 KB |
Output is correct |
5 |
Correct |
16 ms |
2756 KB |
Output is correct |
6 |
Correct |
17 ms |
2756 KB |
Output is correct |
7 |
Correct |
16 ms |
2820 KB |
Output is correct |
8 |
Correct |
16 ms |
2748 KB |
Output is correct |
9 |
Correct |
15 ms |
2804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
2764 KB |
Output is correct |
2 |
Correct |
15 ms |
2800 KB |
Output is correct |
3 |
Correct |
16 ms |
2764 KB |
Output is correct |
4 |
Correct |
16 ms |
2824 KB |
Output is correct |
5 |
Correct |
16 ms |
2756 KB |
Output is correct |
6 |
Correct |
17 ms |
2756 KB |
Output is correct |
7 |
Correct |
16 ms |
2820 KB |
Output is correct |
8 |
Correct |
16 ms |
2748 KB |
Output is correct |
9 |
Correct |
15 ms |
2804 KB |
Output is correct |
10 |
Correct |
23 ms |
3084 KB |
Output is correct |
11 |
Correct |
23 ms |
3124 KB |
Output is correct |
12 |
Correct |
25 ms |
3084 KB |
Output is correct |
13 |
Correct |
22 ms |
3020 KB |
Output is correct |
14 |
Correct |
22 ms |
3020 KB |
Output is correct |
15 |
Correct |
22 ms |
3140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
2764 KB |
Output is correct |
2 |
Correct |
15 ms |
2800 KB |
Output is correct |
3 |
Correct |
16 ms |
2764 KB |
Output is correct |
4 |
Correct |
16 ms |
2824 KB |
Output is correct |
5 |
Correct |
16 ms |
2756 KB |
Output is correct |
6 |
Correct |
17 ms |
2756 KB |
Output is correct |
7 |
Correct |
16 ms |
2820 KB |
Output is correct |
8 |
Correct |
16 ms |
2748 KB |
Output is correct |
9 |
Correct |
15 ms |
2804 KB |
Output is correct |
10 |
Correct |
23 ms |
3084 KB |
Output is correct |
11 |
Correct |
23 ms |
3124 KB |
Output is correct |
12 |
Correct |
25 ms |
3084 KB |
Output is correct |
13 |
Correct |
22 ms |
3020 KB |
Output is correct |
14 |
Correct |
22 ms |
3020 KB |
Output is correct |
15 |
Correct |
22 ms |
3140 KB |
Output is correct |
16 |
Correct |
263 ms |
12028 KB |
Output is correct |
17 |
Correct |
277 ms |
12016 KB |
Output is correct |
18 |
Correct |
259 ms |
12176 KB |
Output is correct |
19 |
Correct |
261 ms |
12048 KB |
Output is correct |
20 |
Correct |
254 ms |
12044 KB |
Output is correct |
21 |
Correct |
237 ms |
12108 KB |
Output is correct |
22 |
Correct |
237 ms |
12008 KB |
Output is correct |
23 |
Correct |
239 ms |
12172 KB |
Output is correct |
24 |
Correct |
243 ms |
12048 KB |
Output is correct |