View Code of Problem 6

count = int(input())

while count:
    num = input()
    arry = []
    # arry = [0 for i in range(int(num))]
    # load_arry = [arry]*2
    for i in range(int(num)):
        a, b = input().split()
        arry.append([int(a), int(b)])

    max = arry[0][1] - arry[0][0]

    for _ in range(int(num)):
        if max < (arry[_][1] - arry[_][0]):
            max = arry[_][1] - arry[_][0]

    p = True

    for i in range(int(num)-1):
        if (arry[i][0] + max > arry[i][1]) or (arry[i][1] + max < arry[i+1][0]):
            p = False

    if p:
        print("YES")
    else:
        print("NO")

    # print(arry)
    # print(max)
    count -= 1

Double click to view unformatted code.


Back to problem 6