前四个数据REpython 求救!!!

P2249 【深基13.例1】查找

qiu147 @ 2024-03-12 19:42:42

n,m = map(int,input().split())
arr = [0]
read = []
find = []
while len(read)<n:
    read += list(map(int,input().split()))
arr += read
while len(find)<m:
    find += list(map(int,input().split()))

def check(mid):
    if arr[mid] < i:
        return True
    else:
        return False

for j in range(m):
    i = find[j]
    l = -1
    r = len(arr)
    mid = 0
    while l < r:
        mid = (l+r+1)>>1 
        if check(mid):
            l = mid
        else:
            r = mid -1
    if arr[l+1] == i:
        print(l+1,end=' ')
    else:
        print(-1,end=' ')

|