結果

問題 No.1120 Strange Teacher
ユーザー 37zigen
提出日時 2020-07-24 11:06:56
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 675 ms / 1,000 ms
コード長 446 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 51,260 KB
最終ジャッジ日時 2024-06-24 21:37:53
合計ジャッジ時間 21,148 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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