結果
問題 | No.1120 Strange Teacher |
ユーザー |
![]() |
提出日時 | 2020-12-25 16:09:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 85 ms / 1,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 82,184 KB |
実行使用メモリ | 103,368 KB |
最終ジャッジ日時 | 2024-09-22 08:56:18 |
合計ジャッジ時間 | 3,099 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
def main(): N = int(input()) if N == 1: a = int(input()) b = int(input()) if b < a: return -1 return b - a A = list(map(int, input().split())) B = list(map(int, input().split())) sa = sum(A) sb = sum(B) if N == 2: if sa != sb: return -1 return abs(A[0] - B[0]) if sb > sa: return -1 if (sa - sb) % (N - 2) != 0: return -1 K = (sa - sb) // (N - 2) A = [a - K for a in A] tmp = 0 for a, b in zip(A, B): op = b - a if op < 0: return - 1 tmp += op // 2 if K == tmp: return K return -1 print(main())