結果

問題 No.1120 Strange Teacher
コンテスト
ユーザー AEn
提出日時 2022-05-21 12:16:30
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 60 ms / 1,000 ms
コード長 520 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 162 ms
コンパイル使用メモリ 85,164 KB
実行使用メモリ 112,776 KB
最終ジャッジ日時 2026-04-08 22:14:09
合計ジャッジ時間 3,070 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
m = []
for i in range(N):
    m.append(A[i]-B[i])
if N == 2:
    if sum(A) != sum(B):
        print(-1)
    else:
        print(abs(A[0]-B[0]))
    exit()
sm = sum(m)
if sm % (N-2) != 0:
    print(-1)
    exit()
res = sm//(N-2)
for i in range(N):
    m[i] -= res
cnt = 0
for i in range(N):
    if m[i]%2!=0 or m[i]>0:
        print(-1)
        exit()
    cnt += -m[i]//2
    if cnt > res:
        print(-1)
        exit()
print(res)
0