Skip to content

Commit aa80ce8

Browse files
authored
[BOJ] 2212 센서 (G5)
1 parent 1a5cc84 commit aa80ce8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

김지호/6주차/260202.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)