結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
29,504 KB
testcase_01 AC 135 ms
29,272 KB
testcase_02 AC 136 ms
29,580 KB
testcase_03 AC 153 ms
30,736 KB
testcase_04 AC 300 ms
41,572 KB
testcase_05 AC 294 ms
41,792 KB
testcase_06 AC 294 ms
41,884 KB
testcase_07 AC 294 ms
41,668 KB
testcase_08 AC 291 ms
41,792 KB
testcase_09 AC 133 ms
29,428 KB
testcase_10 AC 231 ms
42,316 KB
testcase_11 AC 233 ms
42,404 KB
testcase_12 AC 232 ms
42,328 KB
testcase_13 AC 235 ms
41,732 KB
testcase_14 AC 234 ms
41,620 KB
testcase_15 AC 232 ms
41,872 KB
testcase_16 AC 250 ms
41,532 KB
testcase_17 AC 250 ms
41,732 KB
testcase_18 AC 132 ms
29,204 KB
testcase_19 AC 296 ms
41,748 KB
testcase_20 AC 133 ms
29,304 KB
testcase_21 AC 134 ms
29,300 KB
testcase_22 AC 133 ms
29,356 KB
testcase_23 AC 134 ms
29,496 KB
testcase_24 AC 289 ms
41,000 KB
testcase_25 AC 131 ms
29,412 KB
testcase_26 AC 133 ms
29,496 KB
testcase_27 AC 134 ms
29,472 KB
testcase_28 AC 136 ms
29,512 KB
testcase_29 AC 134 ms
29,448 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
    for a,b in zip(A,B):
        if a>b or (b-a)%2==1:
            print(-1)
            exit(0)
    print(t)
0