結果

問題 No.1120 Strange Teacher
ユーザー neterukunneterukun
提出日時 2020-07-22 22:08:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 101,516 KB
最終ジャッジ日時 2023-09-04 20:46:04
合計ジャッジ時間 4,885 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,628 KB
testcase_01 AC 75 ms
71,416 KB
testcase_02 AC 79 ms
75,800 KB
testcase_03 AC 83 ms
76,720 KB
testcase_04 AC 120 ms
101,284 KB
testcase_05 AC 121 ms
101,284 KB
testcase_06 AC 121 ms
101,136 KB
testcase_07 AC 119 ms
101,468 KB
testcase_08 AC 124 ms
101,516 KB
testcase_09 AC 76 ms
71,544 KB
testcase_10 AC 115 ms
101,304 KB
testcase_11 AC 117 ms
101,292 KB
testcase_12 AC 118 ms
101,220 KB
testcase_13 AC 123 ms
101,268 KB
testcase_14 AC 118 ms
101,292 KB
testcase_15 AC 117 ms
101,328 KB
testcase_16 AC 118 ms
101,292 KB
testcase_17 AC 117 ms
101,292 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 76 ms
71,108 KB
testcase_21 AC 74 ms
71,536 KB
testcase_22 AC 76 ms
71,140 KB
testcase_23 AC 76 ms
71,548 KB
testcase_24 AC 116 ms
100,480 KB
testcase_25 AC 73 ms
71,660 KB
testcase_26 AC 74 ms
71,464 KB
testcase_27 AC 75 ms
71,436 KB
testcase_28 AC 79 ms
71,360 KB
testcase_29 AC 79 ms
71,432 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