题解 | 操作数组
操作数组
https://www.nowcoder.com/practice/834c719e740e4a1f8fc4f34f4993c8cf
import sys
# for line in sys.stdin:
# a = line.split()
# print(int(a[0]) + int(a[1]))
def solve():
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sm = 0
res = 0
for i in range(n):
sm += (a[i] - b[i])
res += abs(a[i] - b[i])
return res // 2 if sm == 0 else -1
res = solve()
print(res)
查看7道真题和解析