結果

問題 No.1120 Strange Teacher
ユーザー ayaoniayaoni
提出日時 2020-12-10 22:48:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 869 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 81,600 KB
実行使用メモリ 103,852 KB
最終ジャッジ日時 2023-10-20 00:57:33
合計ジャッジ時間 5,602 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 38 ms
53,392 KB
testcase_10 AC 79 ms
101,356 KB
testcase_11 AC 84 ms
101,360 KB
testcase_12 AC 80 ms
101,364 KB
testcase_13 AC 82 ms
101,228 KB
testcase_14 AC 80 ms
101,224 KB
testcase_15 AC 80 ms
101,224 KB
testcase_16 AC 86 ms
103,688 KB
testcase_17 AC 86 ms
103,692 KB
testcase_18 AC 40 ms
53,392 KB
testcase_19 AC 89 ms
101,536 KB
testcase_20 AC 38 ms
53,392 KB
testcase_21 AC 38 ms
53,392 KB
testcase_22 AC 38 ms
53,392 KB
testcase_23 AC 39 ms
53,392 KB
testcase_24 WA -
testcase_25 AC 38 ms
53,392 KB
testcase_26 AC 40 ms
53,392 KB
testcase_27 AC 39 ms
53,392 KB
testcase_28 AC 41 ms
53,392 KB
testcase_29 AC 38 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) % (N-2) != 0:
        print(-1)
        break
else:
    print(M)
0