結果

問題 No.1120 Strange Teacher
ユーザー rin204rin204
提出日時 2022-07-04 16:41:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 457 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 103,936 KB
最終ジャッジ日時 2024-05-08 06:08:56
合計ジャッジ時間 4,147 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 42 ms
51,456 KB
testcase_10 AC 95 ms
101,760 KB
testcase_11 AC 95 ms
101,632 KB
testcase_12 AC 94 ms
101,888 KB
testcase_13 AC 96 ms
101,632 KB
testcase_14 AC 95 ms
101,248 KB
testcase_15 AC 95 ms
101,504 KB
testcase_16 AC 106 ms
103,424 KB
testcase_17 AC 107 ms
103,168 KB
testcase_18 AC 42 ms
51,712 KB
testcase_19 AC 106 ms
100,480 KB
testcase_20 AC 42 ms
51,968 KB
testcase_21 AC 42 ms
51,456 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 42 ms
51,840 KB
testcase_26 AC 42 ms
51,840 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
tota = sum(A)
totb = sum(B)
if n == 2:
    if tota == totb:
        print(abs(A[0] - B[0]))
    else:
        print(-1)
    exit()
d = tota - totb
if d < 0:
    print(-1)
    exit()
if d % (n - 2) != 0:
    print(-1)
    exit()
cnt = d // (n - 2)
A = [a - cnt for a in A]
tot = sum(max(a - b, 0) for a, b in zip(A, B))
if tot < cnt:
    print(-1)
else:
    print(cnt)
0