n,k=map(int,input().split())
l=[]
for i in range(n):
a=int(input())
l.append(a)
for i in range(len(l)-1):
l[i]=l[i+1]-l[i]-1
s=n
l=sorted(l)
for i in range(n-k):
s+=l[i]
print(s)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
2908 KB |
Output is correct |
2 |
Correct |
10 ms |
2908 KB |
Output is correct |
3 |
Correct |
10 ms |
2908 KB |
Output is correct |
4 |
Correct |
10 ms |
2944 KB |
Output is correct |
5 |
Correct |
10 ms |
2908 KB |
Output is correct |
6 |
Correct |
10 ms |
2960 KB |
Output is correct |
7 |
Correct |
10 ms |
2952 KB |
Output is correct |
8 |
Correct |
10 ms |
2908 KB |
Output is correct |
9 |
Correct |
10 ms |
2908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
2908 KB |
Output is correct |
2 |
Correct |
10 ms |
2908 KB |
Output is correct |
3 |
Correct |
10 ms |
2908 KB |
Output is correct |
4 |
Correct |
10 ms |
2944 KB |
Output is correct |
5 |
Correct |
10 ms |
2908 KB |
Output is correct |
6 |
Correct |
10 ms |
2960 KB |
Output is correct |
7 |
Correct |
10 ms |
2952 KB |
Output is correct |
8 |
Correct |
10 ms |
2908 KB |
Output is correct |
9 |
Correct |
10 ms |
2908 KB |
Output is correct |
10 |
Correct |
14 ms |
3164 KB |
Output is correct |
11 |
Correct |
14 ms |
2980 KB |
Output is correct |
12 |
Correct |
14 ms |
3164 KB |
Output is correct |
13 |
Correct |
14 ms |
3164 KB |
Output is correct |
14 |
Correct |
14 ms |
3164 KB |
Output is correct |
15 |
Correct |
14 ms |
3164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
2908 KB |
Output is correct |
2 |
Correct |
10 ms |
2908 KB |
Output is correct |
3 |
Correct |
10 ms |
2908 KB |
Output is correct |
4 |
Correct |
10 ms |
2944 KB |
Output is correct |
5 |
Correct |
10 ms |
2908 KB |
Output is correct |
6 |
Correct |
10 ms |
2960 KB |
Output is correct |
7 |
Correct |
10 ms |
2952 KB |
Output is correct |
8 |
Correct |
10 ms |
2908 KB |
Output is correct |
9 |
Correct |
10 ms |
2908 KB |
Output is correct |
10 |
Correct |
14 ms |
3164 KB |
Output is correct |
11 |
Correct |
14 ms |
2980 KB |
Output is correct |
12 |
Correct |
14 ms |
3164 KB |
Output is correct |
13 |
Correct |
14 ms |
3164 KB |
Output is correct |
14 |
Correct |
14 ms |
3164 KB |
Output is correct |
15 |
Correct |
14 ms |
3164 KB |
Output is correct |
16 |
Correct |
157 ms |
8796 KB |
Output is correct |
17 |
Correct |
155 ms |
8792 KB |
Output is correct |
18 |
Correct |
158 ms |
8788 KB |
Output is correct |
19 |
Correct |
158 ms |
8940 KB |
Output is correct |
20 |
Correct |
150 ms |
8872 KB |
Output is correct |
21 |
Correct |
144 ms |
8796 KB |
Output is correct |
22 |
Correct |
148 ms |
8792 KB |
Output is correct |
23 |
Correct |
143 ms |
8792 KB |
Output is correct |
24 |
Correct |
146 ms |
8892 KB |
Output is correct |