Skip to content

Commit e54461e

Browse files
committed
수 고르기 풀이
1 parent 06a3e6e commit e54461e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

BAEKJOON/3Gold/수 고르기.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# https://www.acmicpc.net/problem/2230
3+
4+
import sys
5+
input = sys.stdin.readline
6+
7+
N,M = map(int, input().split())
8+
nums = [int(input()) for _ in range(N)]
9+
nums.sort()
10+
11+
end = 0
12+
ans = nums[N-1]-nums[0]
13+
14+
for start in range(N):
15+
while end < N:
16+
diff = nums[end]-nums[start]
17+
if diff >= M:
18+
ans = min(ans, diff)
19+
break
20+
else:
21+
end += 1
22+
23+
print(ans)
24+

BAEKJOON/3Gold/횡단보도.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#
1+
# 그래프 이론, 최단 경로, 데이크스트라
22
# https://www.acmicpc.net/problem/24042
33

44
"""

0 commit comments

Comments
 (0)