結果

問題 No.1120 Strange Teacher
ユーザー 👑 KazunKazun
提出日時 2020-10-31 20:00:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 1,000 ms
コード長 378 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 99,872 KB
最終ジャッジ日時 2023-09-29 10:36:52
合計ジャッジ時間 4,470 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,328 KB
testcase_01 AC 64 ms
71,660 KB
testcase_02 AC 71 ms
75,652 KB
testcase_03 AC 75 ms
76,504 KB
testcase_04 AC 108 ms
99,824 KB
testcase_05 AC 106 ms
99,720 KB
testcase_06 AC 108 ms
99,660 KB
testcase_07 AC 106 ms
99,736 KB
testcase_08 AC 103 ms
99,692 KB
testcase_09 AC 66 ms
71,344 KB
testcase_10 AC 104 ms
99,648 KB
testcase_11 AC 105 ms
99,692 KB
testcase_12 AC 105 ms
99,708 KB
testcase_13 AC 106 ms
99,536 KB
testcase_14 AC 104 ms
99,812 KB
testcase_15 AC 105 ms
99,872 KB
testcase_16 AC 104 ms
99,668 KB
testcase_17 AC 105 ms
99,816 KB
testcase_18 AC 67 ms
71,444 KB
testcase_19 AC 107 ms
97,920 KB
testcase_20 AC 66 ms
71,624 KB
testcase_21 AC 66 ms
71,320 KB
testcase_22 AC 67 ms
71,368 KB
testcase_23 AC 67 ms
71,464 KB
testcase_24 AC 106 ms
99,400 KB
testcase_25 AC 66 ms
71,300 KB
testcase_26 AC 68 ms
71,616 KB
testcase_27 AC 68 ms
71,380 KB
testcase_28 AC 66 ms
71,240 KB
testcase_29 AC 67 ms
71,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

if N==2:
    if sum(A)==sum(B):
        print(abs(A[0]-B[0]))
    else:
        print(-1)
    exit()

D=[B[i]-A[i] for i in range(N)]
X=-sum(D)

for d in D:
    y=X+(N-2)*d
    if not(y>=0 and y%(2*(N-2))==0):
        print(-1)
        exit()

print(X//(N-2))
0