結果
問題 |
No.1120 Strange Teacher
|
ユーザー |
|
提出日時 | 2020-07-26 16:34:39 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 108 ms / 1,000 ms |
コード長 | 436 bytes |
コンパイル時間 | 124 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 25,260 KB |
最終ジャッジ日時 | 2024-06-28 17:25:20 |
合計ジャッジ時間 | 4,051 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
N = int(input()) A = tuple(map(int, input().split())) B = tuple(map(int, input().split())) def is_impossible(b): if b: print(-1) exit() if N == 2: print(abs(A[0] - B[0]) if sum(A) == sum(B) else -1) exit() is_impossible((sum(A) - sum(B)) % (N - 2)) x = (sum(A) - sum(B)) // (N - 2) is_impossible(x < 0) C = [B[i] - (A[i] - x) for i in range(N)] is_impossible(any(c < 0 or c % 2 for c in C)) print(x)