結果

問題 No.1120 Strange Teacher
ユーザー neterukunneterukun
提出日時 2020-07-22 22:09:13
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 117 ms / 1,000 ms
コード長 506 bytes
コンパイル時間 1,297 ms
コンパイル使用メモリ 86,808 KB
実行使用メモリ 101,464 KB
最終ジャッジ日時 2023-09-04 20:50:02
合計ジャッジ時間 5,218 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,396 KB
testcase_01 AC 70 ms
71,064 KB
testcase_02 AC 75 ms
75,852 KB
testcase_03 AC 91 ms
76,392 KB
testcase_04 AC 116 ms
101,164 KB
testcase_05 AC 116 ms
101,228 KB
testcase_06 AC 116 ms
101,088 KB
testcase_07 AC 117 ms
101,092 KB
testcase_08 AC 116 ms
101,108 KB
testcase_09 AC 72 ms
71,364 KB
testcase_10 AC 113 ms
101,196 KB
testcase_11 AC 113 ms
101,288 KB
testcase_12 AC 113 ms
101,220 KB
testcase_13 AC 113 ms
101,084 KB
testcase_14 AC 112 ms
101,224 KB
testcase_15 AC 115 ms
101,264 KB
testcase_16 AC 115 ms
101,244 KB
testcase_17 AC 114 ms
101,464 KB
testcase_18 AC 71 ms
71,208 KB
testcase_19 AC 114 ms
99,768 KB
testcase_20 AC 73 ms
71,108 KB
testcase_21 AC 72 ms
71,212 KB
testcase_22 AC 73 ms
71,284 KB
testcase_23 AC 73 ms
71,260 KB
testcase_24 AC 114 ms
100,416 KB
testcase_25 AC 74 ms
71,520 KB
testcase_26 AC 70 ms
71,272 KB
testcase_27 AC 72 ms
71,316 KB
testcase_28 AC 72 ms
71,380 KB
testcase_29 AC 70 ms
71,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


diff = 0
for i in range(n):
    diff += a[i] - b[i]

if n == 2:
    if sum(a) != sum(b):
        print(-1)
    else:
        print(abs(a[0] - b[0]))
    exit()

if diff % (n - 2) == 0 and diff // (n - 2) >= 0:
    cnt = diff // (n - 2)
else:
    print(-1)
    exit()

for i in range(n):
    d = cnt - (a[i] - b[i])
    if d % 2 == 0 and d >= 0:
        continue
    else:
        print(-1)
        exit()
print(cnt)
0