about summary refs log tree commit diff
path: root/codechef/depchef.py
blob: e4899a1f5d245581e5eab7915bf85df533df8c86 (plain) (blame)
1
2
3
4
5
6
7
8
9
#!/usr/bin/env python3
for _ in range(int(input())):
    input()
    a, d = ([int(i) for i in input().split()] for _ in range(2))
    a.extend((a[0], a[-1]))
    try:
        print(max(d for i, d in enumerate(d) if d > a[i-1] + a[i+1]))
    except ValueError:
        print(-1)