python wa声一片 dalao帮忙找找呗
查看原帖
python wa声一片 dalao帮忙找找呗
596829
pineappe030816楼主2022/3/30 17:04
n, m = map(int, input().split())
list_n = list(map(int, input().split()))
list_aim = list(map(int, input().split()))
sum_list = len(list_aim)
a = []
def check(number, list1, count, long):
    if number == list1[len(list1)//2]:
        if number != list1[len(list1)//2-1] or list1[len(list1)//2] == 1:
            a.append(len(list1)//2+1)
            return
        else:
            return check(number, list1[:len(list1)//2], count, long)

    elif count > (long*2):
        a.append(-1)
        return

    elif number > list1[len(list1)//2]:
        count += 1
        return check(number, list1[len(list1)//2:], count, long)

    else:
        count += 1
        return check(number, list1[:len(list1)//2], count, long)

for i in list_aim:
    check(i, list_n, 0, sum_list)

for i in a:
    print(i, end=' ')
2022/3/30 17:04
加载中...