結果

問題 No.1120 Strange Teacher
ユーザー 37zigen37zigen
提出日時 2020-07-24 11:06:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 253 ms / 1,000 ms
コード長 446 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 52,924 KB
最終ジャッジ日時 2023-09-07 02:56:32
合計ジャッジ時間 9,709 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 185 ms
29,500 KB
testcase_01 AC 130 ms
29,508 KB
testcase_02 AC 131 ms
29,764 KB
testcase_03 AC 141 ms
30,988 KB
testcase_04 AC 250 ms
41,656 KB
testcase_05 AC 253 ms
41,728 KB
testcase_06 AC 250 ms
42,296 KB
testcase_07 AC 248 ms
41,632 KB
testcase_08 AC 250 ms
41,828 KB
testcase_09 AC 137 ms
29,552 KB
testcase_10 AC 231 ms
42,404 KB
testcase_11 AC 232 ms
42,344 KB
testcase_12 AC 232 ms
42,352 KB
testcase_13 AC 236 ms
41,788 KB
testcase_14 AC 229 ms
41,856 KB
testcase_15 AC 230 ms
41,628 KB
testcase_16 AC 246 ms
41,708 KB
testcase_17 AC 250 ms
41,420 KB
testcase_18 AC 130 ms
29,684 KB
testcase_19 AC 253 ms
41,868 KB
testcase_20 AC 131 ms
29,544 KB
testcase_21 AC 130 ms
29,464 KB
testcase_22 AC 133 ms
29,720 KB
testcase_23 AC 128 ms
29,640 KB
testcase_24 AC 243 ms
40,876 KB
testcase_25 AC 126 ms
29,484 KB
testcase_26 AC 128 ms
29,644 KB
testcase_27 AC 129 ms
29,644 KB
testcase_28 AC 132 ms
29,652 KB
testcase_29 AC 126 ms
52,924 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()])
if N==2:
    if sum(A) != sum(B):
        print(-1)
    else:
        print(abs(A[0]-B[0]))
else:
    if sum(A)<sum(B) or (sum(A)-sum(B))%(N-2) !=0:
        print(-1)
        exit(0)
    t=(sum(A)-sum(B))//(N-2)
    A-=t
    res=t
    x=B-A
    if np.all((x>=0) & (x%2==0)):
        print(t)
    else:
        print(-1)
0