結果

問題 No.1120 Strange Teacher
ユーザー AEnAEn
提出日時 2022-05-21 11:47:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 508 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 81,784 KB
実行使用メモリ 103,284 KB
最終ジャッジ日時 2023-10-20 15:51:53
合計ジャッジ時間 5,437 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,500 KB
testcase_01 AC 37 ms
53,500 KB
testcase_02 AC 35 ms
59,504 KB
testcase_03 AC 41 ms
66,332 KB
testcase_04 AC 81 ms
103,080 KB
testcase_05 AC 79 ms
103,080 KB
testcase_06 AC 82 ms
103,032 KB
testcase_07 AC 80 ms
103,080 KB
testcase_08 AC 81 ms
103,080 KB
testcase_09 AC 34 ms
53,500 KB
testcase_10 AC 77 ms
103,284 KB
testcase_11 AC 78 ms
103,284 KB
testcase_12 AC 76 ms
103,284 KB
testcase_13 AC 83 ms
103,080 KB
testcase_14 AC 81 ms
103,080 KB
testcase_15 AC 80 ms
103,080 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 33 ms
53,500 KB
testcase_19 AC 84 ms
100,388 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 34 ms
53,500 KB
testcase_23 AC 33 ms
53,500 KB
testcase_24 AC 78 ms
102,324 KB
testcase_25 AC 33 ms
53,500 KB
testcase_26 AC 34 ms
53,500 KB
testcase_27 AC 34 ms
53,500 KB
testcase_28 AC 34 ms
53,500 KB
testcase_29 AC 33 ms
53,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if N==2 and B[0]-A[0] == -(B[1]-A[1]):
    print(abs(B[0]-A[0]))
elif N == 2:
    print(-1)
    exit()
s = 0
m = []
for i in range(N):
    s += (B[i]-A[i])
    m.append(B[i]-A[i])
sm, mod = divmod(s, 2-N)
if mod != 0:
    print(-1)
    exit()
else:
    res = 0
    for i in range(N):
        if (m[i]+sm)%2 == 1:
            print(-1)
            exit()
        else:
            res += abs((m[i]+sm)//2)
    print(res)
0