結果

問題 No.1120 Strange Teacher
コンテスト
ユーザー 37zigen
提出日時 2020-07-24 11:10:54
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 610 ms / 1,000 ms
コード長 552 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 474 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 44,948 KB
最終ジャッジ日時 2026-03-11 01:52:44
合計ジャッジ時間 18,660 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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