結果

問題 No.1120 Strange Teacher
コンテスト
ユーザー brthyyjp
提出日時 2020-08-02 01:44:14
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 63 ms / 1,000 ms
+ 56µs
コード長 538 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 75 ms
コンパイル使用メモリ 65,092 KB
実行使用メモリ 79,324 KB
最終ジャッジ日時 2026-10-13 22:25:48
合計ジャッジ時間 4,495 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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