結果

問題 No.1120 Strange Teacher
ユーザー H20
提出日時 2021-08-24 11:20:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 502 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 82,104 KB
実行使用メモリ 103,428 KB
最終ジャッジ日時 2024-11-14 03:52:46
合計ジャッジ時間 4,354 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
SA = sum(A)
SB = sum(B)
if N==2:
    if SA==SB:
        print(abs(B[0]-A[0]))
    else:
        print(-1)
    exit()


if (SA-SB)%(N-2)==0:
    cnt = (SA-SB)//(N-2)
    temp = 0
    for i in range(N):
        if B[i]-(A[i]-cnt)<0 or B[i]-(A[i]-cnt)%2==1:
            print(-1)
            exit()
        temp += B[i]-(A[i]-cnt)
    if temp//2==cnt:
        print(cnt)
    else:
        print(-1)
else:
    print(-1)
0