We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 58d9e53 commit 74d35e4Copy full SHA for 74d35e4
1 file changed
김지호/8주차/260220.py
@@ -0,0 +1,31 @@
1
+# https://www.acmicpc.net/problem/1920
2
+# 수 찾기, 실버4
3
+
4
+import sys
5
+sys.stdin = open('../../../input.txt', 'r')
6
7
+N = int(input().strip())
8
+numbers = list(map(int, input().strip().split()))
9
+M = int(input().strip())
10
+targets = list(map(int, input().strip().split()))
11
12
+numbers.sort()
13
14
+for target in targets:
15
+ left, right = 0, N - 1
16
+ found = False
17
18
+ while left <= right:
19
+ mid = (left + right) // 2
20
21
+ if target == numbers[mid]:
22
+ found = True
23
+ print(1)
24
+ break
25
+ elif target > numbers[mid]:
26
+ left = mid + 1
27
+ else:
28
+ right = mid - 1
29
30
+ if not found:
31
+ print(0)
0 commit comments