We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d7472cf commit a48ee81Copy full SHA for a48ee81
1 file changed
live8/test84/문제1/박희경.py
@@ -0,0 +1,39 @@
1
+import sys
2
+
3
+input = sys.stdin.readline
4
5
6
+def binary_search(arr, target):
7
+ start, end = 0, m - 1
8
+ cnt = 0
9
+ while start <= end:
10
+ mid = (start + end) // 2
11
+ if arr[mid] < target: # 먹이가 작은 상황
12
+ cnt = mid + 1
13
+ start = mid + 1
14
+ else: # 먹이가 더 큰 상황
15
+ end = mid - 1
16
+ return cnt
17
18
19
+t = int(input())
20
+for _ in range(t):
21
+ n, m = map(int, input().split())
22
+ a = list(map(int, input().split()))
23
+ b = list(map(int, input().split()))
24
25
+ b.sort()
26
+ result = 0
27
+ for i in range(len(a)):
28
+ result += binary_search(b, a[i])
29
+ print(result)
30
31
+"""
32
+2
33
+5 3
34
+8 1 7 3 1
35
+3 6 1
36
+3 4
37
+2 13 7
38
+103 11 290 215
39
0 commit comments