結果

問題 No.1120 Strange Teacher
ユーザー 👑 rin204rin204
提出日時 2022-07-04 16:41:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 457 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 87,360 KB
実行使用メモリ 101,496 KB
最終ジャッジ日時 2023-08-21 00:25:09
合計ジャッジ時間 4,586 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,292 KB
testcase_10 AC 111 ms
101,040 KB
testcase_11 AC 110 ms
101,196 KB
testcase_12 AC 111 ms
100,996 KB
testcase_13 AC 111 ms
101,256 KB
testcase_14 AC 112 ms
100,992 KB
testcase_15 AC 112 ms
101,312 KB
testcase_16 AC 117 ms
100,988 KB
testcase_17 AC 118 ms
100,996 KB
testcase_18 AC 70 ms
70,924 KB
testcase_19 AC 114 ms
99,444 KB
testcase_20 AC 69 ms
71,312 KB
testcase_21 AC 69 ms
71,156 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 69 ms
71,372 KB
testcase_26 AC 70 ms
71,284 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