【华为OD机试真题 python】数轴上两个点集距离

 

 

python:

def function():
    l1 = input().split(" ")
    l2 = input().split(" ")
    l3 = input().split(" ")
    m, n, R = int(l1[0]), int(l1[1]), int(l1[2])
    A = [int(i) for i in l2]
    B = [int(i) for i in l3]

    res = []
    for i in range(m):
        for j in range(n):
            if A[i] <= B[j] and B[j] - A[i] <= R:
                res.append([A[i], B[j]])
                break

    for i in range(len(res)):
        print(res[i][0], res[i][1])


if __name__ == '__main__':
    function()

 

posted @ 2023-10-24 17:42  年轻人——001  阅读(8)  评论(0编辑  收藏  举报