結果
問題 | No.1120 Strange Teacher |
ユーザー |
![]() |
提出日時 | 2020-07-24 21:38:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 106 ms / 1,000 ms |
コード長 | 618 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 102,912 KB |
最終ジャッジ日時 | 2024-06-25 20:47:26 |
合計ジャッジ時間 | 3,624 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
import sysinput = sys.stdin.readlineN = int(input())A = list(map(int, input().split()))B = list(map(int, input().split()))C = [B[i]-A[i] for i in range(N)]if N==2:if abs(C[0])!=abs(C[1]):print(-1)else:print(abs(C[0]))exit()D = []for i in range(1, N):if (C[0]-C[i])%2==1:print(-1)exit()D.append((C[0]-C[i])//2)S = sum(D)if (S-C[0])%(N-2)!=0:print(-1)exit()x = (S-C[0])//(N-2)if x<0:print(-1)exit()ans = xfor Di in D:if x-Di<0:print(-1)exit()ans += x-Diprint(ans)