当前位置:网站首页>Cf:b. array determinations

Cf:b. array determinations

2022-06-11 18:47:00 Review of the white speed Dragon King

 Insert picture description here

analysis

according to a and b Value , Find the maximum value that can be deleted
Then for all a All minus this maximum , If it is less than 0 Then take 0
Look at this result and b Whether it is consistent or not

ac code

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    maxReduce = 0
    for i in range(n):
        maxReduce = max(maxReduce, a[i] - b[i])

    expectedB = []
    for i in range(n):
        now = max(0, a[i] - maxReduce)
        expectedB.append(now)

    if expectedB != b:
        print('NO')
    else:
        print('YES')

summary

Maximum simulation

原网站

版权声明
本文为[Review of the white speed Dragon King]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111836367017.html