結果

問題 No.1120 Strange Teacher
ユーザー lloyzlloyz
提出日時 2023-05-14 00:21:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 101,364 KB
最終ジャッジ日時 2023-08-19 19:56:33
合計ジャッジ時間 5,953 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 71 ms
71,148 KB
testcase_10 AC 111 ms
101,052 KB
testcase_11 AC 112 ms
101,048 KB
testcase_12 AC 111 ms
100,996 KB
testcase_13 AC 112 ms
101,060 KB
testcase_14 AC 111 ms
100,988 KB
testcase_15 AC 113 ms
101,080 KB
testcase_16 AC 111 ms
100,972 KB
testcase_17 AC 112 ms
100,908 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 71 ms
71,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 71 ms
71,400 KB
testcase_26 AC 72 ms
71,412 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 71 ms
71,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if sum(A) >= sum(B):
    print(-1)
    exit()
D = []
for i in range(n):
    D.append(B[i] - A[i])
sumD = sum(D)
if n == 2:
    if sumD == 0:
        print(abs(D[0]))
    else:
        print(-1)
elif sumD < 0 and abs(sumD) % (n - 2) == 0:
    cnt = abs(sumD) // (n - 2)
    res = 0
    for i in range(n):
        if D[i] + cnt < 0 or (D[i] + cnt) % 2 != 0:
            print(-1)
            exit()
        res += (D[i] + cnt) // 2
    if res == cnt:
        print(cnt)
    else:
        print(-1)
else:
    print(-1)
0