結果

問題 No.1120 Strange Teacher
ユーザー 37zigen37zigen
提出日時 2020-07-24 11:10:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 261 ms / 1,000 ms
コード長 552 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 42,500 KB
最終ジャッジ日時 2023-09-07 03:02:57
合計ジャッジ時間 7,711 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
29,624 KB
testcase_01 AC 136 ms
29,656 KB
testcase_02 AC 138 ms
29,772 KB
testcase_03 AC 148 ms
30,940 KB
testcase_04 AC 257 ms
41,392 KB
testcase_05 AC 255 ms
41,932 KB
testcase_06 AC 258 ms
42,320 KB
testcase_07 AC 257 ms
41,416 KB
testcase_08 AC 259 ms
41,780 KB
testcase_09 AC 139 ms
29,348 KB
testcase_10 AC 237 ms
42,276 KB
testcase_11 AC 235 ms
42,500 KB
testcase_12 AC 239 ms
42,276 KB
testcase_13 AC 238 ms
41,864 KB
testcase_14 AC 238 ms
41,872 KB
testcase_15 AC 239 ms
41,776 KB
testcase_16 AC 259 ms
41,792 KB
testcase_17 AC 261 ms
41,896 KB
testcase_18 AC 139 ms
29,856 KB
testcase_19 AC 258 ms
41,704 KB
testcase_20 AC 140 ms
29,472 KB
testcase_21 AC 138 ms
29,548 KB
testcase_22 AC 136 ms
29,752 KB
testcase_23 AC 138 ms
29,700 KB
testcase_24 AC 255 ms
41,064 KB
testcase_25 AC 139 ms
29,528 KB
testcase_26 AC 140 ms
29,548 KB
testcase_27 AC 139 ms
29,688 KB
testcase_28 AC 140 ms
29,640 KB
testcase_29 AC 139 ms
29,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()])
B = np.array([int(x) for x in input().split()])
def main(A,B):
    if N == 2:
        if sum(A) != sum(B):
            return -1
        else:
            return abs(A[0] - B[0])
    else:
        if sum(A) < sum(B) or (sum(A) - sum(B)) % (N - 2) != 0:
            return -1
        t = (sum(A) - sum(B)) // (N - 2)
        A -= t
        x = B - A
        if np.all((x >= 0) & (x % 2 == 0)):
            return t
        else:
            return -1
print(main(A,B))
0