第六题对,其他全RE了,有没有大佬帮我看看这么个事

P2249 【深基13.例1】查找

__cat__QWQ @ 2024-02-02 09:38:29

a = input().split(" ")
n = int(a[0])
m = int(a[1])
dic = list(map(int, input().split(" ")))
find = list(map(int, input().split(" ")))
ans = []
for k in find:
    i = 0
    j = n
    while i < j:
        m = (i + j) // 2
        if dic[m] < k:
            i = m + 1
        else:
            j = m
    if dic[i] == k:
        ans.append(str(i + 1))
    else:
        ans.append("-1")
print(" ".join(ans))

by gghvcchb @ 2024-03-06 09:36:05

@catQWQ 兄弟,找到原因了吗


|