結果
問題 | No.1120 Strange Teacher |
ユーザー |
![]() |
提出日時 | 2022-05-21 11:47:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 508 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 103,680 KB |
最終ジャッジ日時 | 2024-09-20 11:25:16 |
合計ジャッジ時間 | 4,675 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 2 RE * 2 |
ソースコード
N = int(input())A = list(map(int, input().split()))B = list(map(int, input().split()))if N==2 and B[0]-A[0] == -(B[1]-A[1]):print(abs(B[0]-A[0]))elif N == 2:print(-1)exit()s = 0m = []for i in range(N):s += (B[i]-A[i])m.append(B[i]-A[i])sm, mod = divmod(s, 2-N)if mod != 0:print(-1)exit()else:res = 0for i in range(N):if (m[i]+sm)%2 == 1:print(-1)exit()else:res += abs((m[i]+sm)//2)print(res)