結果

問題 No.1120 Strange Teacher
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-02 01:44:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 1,000 ms
コード長 538 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 82,000 KB
実行使用メモリ 103,840 KB
最終ジャッジ日時 2024-07-16 00:49:21
合計ジャッジ時間 3,807 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

if n == 2:
    if B[0]-A[0] != A[1]-B[1]:
        print(-1)
        exit()
    else:
        print(abs(B[0]-A[0]))
        exit()

S = 0
for a, b in zip(A, B):
    S += a-b
#print(S)
if S%(n-2) == 0:
    x = S//(n-2)
    for a, b in zip(A, B):
        if b-a+x < 0:
            print(-1)
            exit()
        else:
            if (b-a+x)%2 != 0:
                print(-1)
                exit()
    else:
        print(x)
else:
    print(-1)
0