We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1a5cc84 commit aa80ce8Copy full SHA for aa80ce8
1 file changed
김지호/6주차/260202.py
@@ -0,0 +1,22 @@
1
+# https://www.acmicpc.net/problem/2212
2
+# 센서, 골드5
3
+
4
+from collections import deque
5
6
+import sys
7
+sys.stdin = open("../../../input.txt",'r')
8
9
10
+N = int(input()) # 센서 개수
11
+K = int(input()) # 집중국 개수
12
13
+coordinates = list(map(int,input().split(" "))) # 센서 위치
14
+coordinates.sort()
15
16
+gaps = []
17
+for i in range(1,len(coordinates)):
18
+ gaps.append(coordinates[i] - coordinates[i-1])
19
20
+gaps.sort() # 오름차순
21
+answer = sum(gaps[0:N-K])
22
+print(answer)
0 commit comments