結果

問題 No.1120 Strange Teacher
ユーザー ayaoniayaoni
提出日時 2020-12-10 22:52:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 1,000 ms
コード長 865 bytes
コンパイル時間 983 ms
コンパイル使用メモリ 81,428 KB
実行使用メモリ 103,924 KB
最終ジャッジ日時 2023-10-20 00:58:07
合計ジャッジ時間 3,741 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,392 KB
testcase_01 AC 38 ms
53,392 KB
testcase_02 AC 40 ms
59,364 KB
testcase_03 AC 44 ms
63,936 KB
testcase_04 AC 81 ms
103,916 KB
testcase_05 AC 82 ms
103,916 KB
testcase_06 AC 83 ms
103,876 KB
testcase_07 AC 91 ms
103,920 KB
testcase_08 AC 82 ms
103,924 KB
testcase_09 AC 35 ms
53,392 KB
testcase_10 AC 75 ms
101,352 KB
testcase_11 AC 77 ms
101,356 KB
testcase_12 AC 75 ms
101,352 KB
testcase_13 AC 73 ms
101,224 KB
testcase_14 AC 74 ms
101,220 KB
testcase_15 AC 74 ms
101,220 KB
testcase_16 AC 80 ms
103,684 KB
testcase_17 AC 79 ms
103,692 KB
testcase_18 AC 34 ms
53,392 KB
testcase_19 AC 82 ms
101,504 KB
testcase_20 AC 36 ms
53,392 KB
testcase_21 AC 35 ms
53,392 KB
testcase_22 AC 39 ms
53,392 KB
testcase_23 AC 35 ms
53,392 KB
testcase_24 AC 77 ms
101,660 KB
testcase_25 AC 37 ms
53,392 KB
testcase_26 AC 35 ms
53,392 KB
testcase_27 AC 35 ms
53,392 KB
testcase_28 AC 35 ms
53,392 KB
testcase_29 AC 35 ms
53,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
A,B = LI(),LI()

sum_A = sum(A)
sum_B = sum(B)

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

if sum_A < sum_B or (sum_A-sum_B) % (N-2) != 0:
    print(-1)
    exit()

M = (sum_A-sum_B)//(N-2)
A = [A[i]-M for i in range(N)]

for i in range(N):
    a,b = A[i],B[i]
    if a > b or (b-a) % 2 != 0:
        print(-1)
        break
else:
    print(M)
0