python3求调 样例能过,提交就4个RE和2个TLE

P2249 【深基13.例1】查找

Chen_Yu_Wei @ 2024-08-15 19:16:13

n,m = map(int,input().split())
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
x = []

for i in l2:
    s = len(l1)//2
    x = [s]
    while 1:
        if i==l1[s]:
            while i==l1[s]:
                s -= 1
            print(s+2,end=' ')
            break
        elif i<l1[s]:
            s = s//2
        else:
            s = s+s//2

        if s in x:
            print(-1,end=' ')
            break

        x.append(s)

|