n, k = map(int, input().split())
l = []
for i in range(n):
l.append(int(input()))
d = []
for i in range(1, n):
d.append(l[i] - l[i - 1])
d = sorted(d)
ans = 0
for i in range(n - k):
ans += d[i] - 1
print(ans + n)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
3308 KB |
Output is correct |
2 |
Correct |
22 ms |
3308 KB |
Output is correct |
3 |
Correct |
19 ms |
3308 KB |
Output is correct |
4 |
Correct |
21 ms |
3308 KB |
Output is correct |
5 |
Correct |
19 ms |
3308 KB |
Output is correct |
6 |
Correct |
19 ms |
3300 KB |
Output is correct |
7 |
Correct |
21 ms |
3308 KB |
Output is correct |
8 |
Correct |
19 ms |
3300 KB |
Output is correct |
9 |
Correct |
19 ms |
3308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
3308 KB |
Output is correct |
2 |
Correct |
22 ms |
3308 KB |
Output is correct |
3 |
Correct |
19 ms |
3308 KB |
Output is correct |
4 |
Correct |
21 ms |
3308 KB |
Output is correct |
5 |
Correct |
19 ms |
3308 KB |
Output is correct |
6 |
Correct |
19 ms |
3300 KB |
Output is correct |
7 |
Correct |
21 ms |
3308 KB |
Output is correct |
8 |
Correct |
19 ms |
3300 KB |
Output is correct |
9 |
Correct |
19 ms |
3308 KB |
Output is correct |
10 |
Correct |
31 ms |
3528 KB |
Output is correct |
11 |
Correct |
32 ms |
3660 KB |
Output is correct |
12 |
Correct |
32 ms |
3524 KB |
Output is correct |
13 |
Correct |
28 ms |
3524 KB |
Output is correct |
14 |
Correct |
30 ms |
3644 KB |
Output is correct |
15 |
Correct |
34 ms |
3652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
3308 KB |
Output is correct |
2 |
Correct |
22 ms |
3308 KB |
Output is correct |
3 |
Correct |
19 ms |
3308 KB |
Output is correct |
4 |
Correct |
21 ms |
3308 KB |
Output is correct |
5 |
Correct |
19 ms |
3308 KB |
Output is correct |
6 |
Correct |
19 ms |
3300 KB |
Output is correct |
7 |
Correct |
21 ms |
3308 KB |
Output is correct |
8 |
Correct |
19 ms |
3300 KB |
Output is correct |
9 |
Correct |
19 ms |
3308 KB |
Output is correct |
10 |
Correct |
31 ms |
3528 KB |
Output is correct |
11 |
Correct |
32 ms |
3660 KB |
Output is correct |
12 |
Correct |
32 ms |
3524 KB |
Output is correct |
13 |
Correct |
28 ms |
3524 KB |
Output is correct |
14 |
Correct |
30 ms |
3644 KB |
Output is correct |
15 |
Correct |
34 ms |
3652 KB |
Output is correct |
16 |
Correct |
377 ms |
13340 KB |
Output is correct |
17 |
Correct |
377 ms |
13440 KB |
Output is correct |
18 |
Correct |
365 ms |
13460 KB |
Output is correct |
19 |
Correct |
376 ms |
13344 KB |
Output is correct |
20 |
Correct |
399 ms |
13468 KB |
Output is correct |
21 |
Correct |
340 ms |
13344 KB |
Output is correct |
22 |
Correct |
357 ms |
13500 KB |
Output is correct |
23 |
Correct |
362 ms |
13344 KB |
Output is correct |
24 |
Correct |
355 ms |
13336 KB |
Output is correct |