結果
| 問題 |
No.1120 Strange Teacher
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-04 16:43:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 1,000 ms |
| コード長 | 478 bytes |
| コンパイル時間 | 828 ms |
| コンパイル使用メモリ | 81,940 KB |
| 実行使用メモリ | 103,784 KB |
| 最終ジャッジ日時 | 2024-12-14 07:41:26 |
| 合計ジャッジ時間 | 4,164 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
tota = sum(A)
totb = sum(B)
if n == 2:
if tota == totb:
print(abs(A[0] - B[0]))
else:
print(-1)
exit()
d = tota - totb
if d < 0:
print(-1)
exit()
if d % (n - 2) != 0:
print(-1)
exit()
cnt = d // (n - 2)
A = [a - cnt for a in A]
tot = 0
for a, b in zip(A, B):
d = b - a
if d < 0 or d & 1:
print(-1)
exit()
print(cnt)