結果

問題 No.1120 Strange Teacher
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-02 01:44:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 116 ms / 1,000 ms
コード長 538 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 101,356 KB
最終ジャッジ日時 2023-09-23 00:14:44
合計ジャッジ時間 4,713 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,384 KB
testcase_01 AC 75 ms
71,484 KB
testcase_02 AC 74 ms
75,692 KB
testcase_03 AC 79 ms
76,416 KB
testcase_04 AC 116 ms
101,268 KB
testcase_05 AC 115 ms
101,136 KB
testcase_06 AC 114 ms
101,244 KB
testcase_07 AC 114 ms
101,176 KB
testcase_08 AC 115 ms
101,204 KB
testcase_09 AC 69 ms
71,428 KB
testcase_10 AC 109 ms
101,176 KB
testcase_11 AC 112 ms
101,184 KB
testcase_12 AC 111 ms
101,152 KB
testcase_13 AC 113 ms
101,144 KB
testcase_14 AC 113 ms
101,196 KB
testcase_15 AC 111 ms
101,356 KB
testcase_16 AC 111 ms
101,184 KB
testcase_17 AC 111 ms
101,144 KB
testcase_18 AC 71 ms
71,548 KB
testcase_19 AC 112 ms
99,808 KB
testcase_20 AC 72 ms
71,272 KB
testcase_21 AC 72 ms
71,404 KB
testcase_22 AC 73 ms
71,116 KB
testcase_23 AC 71 ms
71,564 KB
testcase_24 AC 113 ms
100,384 KB
testcase_25 AC 69 ms
71,512 KB
testcase_26 AC 68 ms
71,416 KB
testcase_27 AC 69 ms
71,292 KB
testcase_28 AC 70 ms
71,424 KB
testcase_29 AC 68 ms
71,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

S = 0
for a, b in zip(A, B):
    S += a-b
#print(S)
if S%(n-2) == 0:
    x = S//(n-2)
    for a, b in zip(A, B):
        if b-a+x < 0:
            print(-1)
            exit()
        else:
            if (b-a+x)%2 != 0:
                print(-1)
                exit()
    else:
        print(x)
else:
    print(-1)
0