結果
問題 | No.1120 Strange Teacher |
ユーザー |
|
提出日時 | 2023-05-14 00:21:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 606 bytes |
コンパイル時間 | 499 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 102,268 KB |
最終ジャッジ日時 | 2024-11-29 15:19:13 |
合計ジャッジ時間 | 3,496 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 12 WA * 15 |
ソースコード
n = int(input())A = list(map(int, input().split()))B = list(map(int, input().split()))if sum(A) >= sum(B):print(-1)exit()D = []for i in range(n):D.append(B[i] - A[i])sumD = sum(D)if n == 2:if sumD == 0:print(abs(D[0]))else:print(-1)elif sumD < 0 and abs(sumD) % (n - 2) == 0:cnt = abs(sumD) // (n - 2)res = 0for i in range(n):if D[i] + cnt < 0 or (D[i] + cnt) % 2 != 0:print(-1)exit()res += (D[i] + cnt) // 2if res == cnt:print(cnt)else:print(-1)else:print(-1)