結果

問題 No.1120 Strange Teacher
ユーザー stng
提出日時 2022-09-04 18:42:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 426 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 92,520 KB
最終ジャッジ日時 2024-11-19 01:09:29
合計ジャッジ時間 3,802 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

li = [0]*n
ans = 0
for i in range(n):
    li[i] = b[i]-a[i]

li.sort(reverse=True)
ans = li[0]
now = -li[0]

for i in range(1,n):
    #print(now,li[i],ans)
    if now == li[i]:
        continue
    elif abs(now+li[i]) % i == 0:
        ans += abs(now-li[i])
        now = li[i]
    else:
        print(-1)
        exit()

print(ans)
0