結果

問題 No.1120 Strange Teacher
ユーザー H3PO4H3PO4
提出日時 2020-07-26 16:34:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 92 ms / 1,000 ms
コード長 436 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 23,896 KB
最終ジャッジ日時 2023-09-11 02:53:37
合計ジャッジ時間 3,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,860 KB
testcase_01 AC 16 ms
7,852 KB
testcase_02 AC 17 ms
8,236 KB
testcase_03 AC 23 ms
9,692 KB
testcase_04 AC 91 ms
23,672 KB
testcase_05 AC 92 ms
23,768 KB
testcase_06 AC 92 ms
23,728 KB
testcase_07 AC 90 ms
23,700 KB
testcase_08 AC 92 ms
23,724 KB
testcase_09 AC 16 ms
8,128 KB
testcase_10 AC 74 ms
23,840 KB
testcase_11 AC 73 ms
23,860 KB
testcase_12 AC 74 ms
23,896 KB
testcase_13 AC 74 ms
23,800 KB
testcase_14 AC 73 ms
23,724 KB
testcase_15 AC 73 ms
23,764 KB
testcase_16 AC 84 ms
23,708 KB
testcase_17 AC 85 ms
23,760 KB
testcase_18 AC 16 ms
7,812 KB
testcase_19 AC 92 ms
23,732 KB
testcase_20 AC 16 ms
8,296 KB
testcase_21 AC 16 ms
8,152 KB
testcase_22 AC 16 ms
8,200 KB
testcase_23 AC 16 ms
7,768 KB
testcase_24 AC 87 ms
20,712 KB
testcase_25 AC 16 ms
8,244 KB
testcase_26 AC 15 ms
8,176 KB
testcase_27 AC 16 ms
7,856 KB
testcase_28 AC 16 ms
7,844 KB
testcase_29 AC 15 ms
8,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0