Skip to content

Commit 20d3cd9

Browse files
committed
로봇 프로젝트
1 parent 98b5687 commit 20d3cd9

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

[Week18 - Search]/이현동/3649.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,45 @@
99
테스트의 개수
1010
레고 조각의 수
1111
구멍의 너비 x
12-
'''
12+
1 센티미터 = 10000000 나노미터
13+
'''
14+
15+
import sys
16+
input = sys.stdin.readline
17+
18+
SIZE = 10000000 # 단위, 나노미터 1센티미터
19+
20+
def findRightHole(N, hole, target):
21+
l, r = 0, N-1
22+
23+
while l < r:
24+
tmp = (hole[l] + hole[r])
25+
26+
if tmp == target:
27+
return [hole[l], hole[r]]
28+
elif tmp < target:
29+
l += 1
30+
else:
31+
r -= 1
32+
33+
return [0, 0]
34+
35+
while True:
36+
try:
37+
x = int(input())
38+
N = int(input())
39+
hole = []
40+
x *= SIZE
41+
for _ in range(N):
42+
hole.append(int(input()))
43+
44+
hole.sort()
45+
46+
47+
ret = findRightHole(N, hole, x)
48+
if ret == [0, 0]:
49+
print("danger")
50+
else:
51+
print("yes {} {}".format(ret[0], ret[1]))
52+
except:
53+
break

0 commit comments

Comments
 (0)