結果

問題 No.1120 Strange Teacher
コンテスト
ユーザー 37zigen
提出日時 2020-07-24 11:06:56
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 646 ms / 1,000 ms
コード長 446 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 389 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 44,924 KB
最終ジャッジ日時 2026-03-11 01:47:27
合計ジャッジ時間 19,946 ms
ジャッジサーバーID
(参考情報)
judge3_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()])
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