We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 98b5687 commit 20d3cd9Copy full SHA for 20d3cd9
[Week18 - Search]/이현동/3649.py
@@ -9,4 +9,45 @@
9
테스트의 개수
10
레고 조각의 수
11
구멍의 너비 x
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
51
+ print("yes {} {}".format(ret[0], ret[1]))
52
+ except:
53
+ break
0 commit comments