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 |
15 ms |
2764 KB |
Output is correct |
2 |
Correct |
15 ms |
2764 KB |
Output is correct |
3 |
Correct |
16 ms |
2720 KB |
Output is correct |
4 |
Correct |
15 ms |
2780 KB |
Output is correct |
5 |
Correct |
16 ms |
2712 KB |
Output is correct |
6 |
Correct |
20 ms |
2796 KB |
Output is correct |
7 |
Correct |
20 ms |
2836 KB |
Output is correct |
8 |
Correct |
16 ms |
2840 KB |
Output is correct |
9 |
Correct |
16 ms |
2800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
2764 KB |
Output is correct |
2 |
Correct |
15 ms |
2764 KB |
Output is correct |
3 |
Correct |
16 ms |
2720 KB |
Output is correct |
4 |
Correct |
15 ms |
2780 KB |
Output is correct |
5 |
Correct |
16 ms |
2712 KB |
Output is correct |
6 |
Correct |
20 ms |
2796 KB |
Output is correct |
7 |
Correct |
20 ms |
2836 KB |
Output is correct |
8 |
Correct |
16 ms |
2840 KB |
Output is correct |
9 |
Correct |
16 ms |
2800 KB |
Output is correct |
10 |
Correct |
29 ms |
3048 KB |
Output is correct |
11 |
Correct |
24 ms |
3108 KB |
Output is correct |
12 |
Correct |
29 ms |
3120 KB |
Output is correct |
13 |
Correct |
28 ms |
3068 KB |
Output is correct |
14 |
Correct |
23 ms |
3000 KB |
Output is correct |
15 |
Correct |
22 ms |
3108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
2764 KB |
Output is correct |
2 |
Correct |
15 ms |
2764 KB |
Output is correct |
3 |
Correct |
16 ms |
2720 KB |
Output is correct |
4 |
Correct |
15 ms |
2780 KB |
Output is correct |
5 |
Correct |
16 ms |
2712 KB |
Output is correct |
6 |
Correct |
20 ms |
2796 KB |
Output is correct |
7 |
Correct |
20 ms |
2836 KB |
Output is correct |
8 |
Correct |
16 ms |
2840 KB |
Output is correct |
9 |
Correct |
16 ms |
2800 KB |
Output is correct |
10 |
Correct |
29 ms |
3048 KB |
Output is correct |
11 |
Correct |
24 ms |
3108 KB |
Output is correct |
12 |
Correct |
29 ms |
3120 KB |
Output is correct |
13 |
Correct |
28 ms |
3068 KB |
Output is correct |
14 |
Correct |
23 ms |
3000 KB |
Output is correct |
15 |
Correct |
22 ms |
3108 KB |
Output is correct |
16 |
Correct |
277 ms |
11864 KB |
Output is correct |
17 |
Correct |
287 ms |
11928 KB |
Output is correct |
18 |
Correct |
280 ms |
11872 KB |
Output is correct |
19 |
Correct |
277 ms |
11824 KB |
Output is correct |
20 |
Correct |
263 ms |
12024 KB |
Output is correct |
21 |
Correct |
257 ms |
11968 KB |
Output is correct |
22 |
Correct |
263 ms |
11920 KB |
Output is correct |
23 |
Correct |
257 ms |
11856 KB |
Output is correct |
24 |
Correct |
253 ms |
11924 KB |
Output is correct |