結果

問題 No.1120 Strange Teacher
ユーザー 👑 rin204rin204
提出日時 2022-07-04 16:43:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 1,000 ms
コード長 478 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 87,332 KB
実行使用メモリ 101,296 KB
最終ジャッジ日時 2023-08-21 00:27:29
合計ジャッジ時間 5,808 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,192 KB
testcase_01 AC 72 ms
71,424 KB
testcase_02 AC 75 ms
75,612 KB
testcase_03 AC 80 ms
76,380 KB
testcase_04 AC 114 ms
101,164 KB
testcase_05 AC 116 ms
101,004 KB
testcase_06 AC 117 ms
101,148 KB
testcase_07 AC 119 ms
101,068 KB
testcase_08 AC 116 ms
101,196 KB
testcase_09 AC 72 ms
71,268 KB
testcase_10 AC 112 ms
101,036 KB
testcase_11 AC 113 ms
100,988 KB
testcase_12 AC 113 ms
101,156 KB
testcase_13 AC 113 ms
101,100 KB
testcase_14 AC 114 ms
101,052 KB
testcase_15 AC 112 ms
101,296 KB
testcase_16 AC 114 ms
101,176 KB
testcase_17 AC 114 ms
101,012 KB
testcase_18 AC 71 ms
71,340 KB
testcase_19 AC 116 ms
99,664 KB
testcase_20 AC 72 ms
71,004 KB
testcase_21 AC 73 ms
71,468 KB
testcase_22 AC 71 ms
71,352 KB
testcase_23 AC 71 ms
71,480 KB
testcase_24 AC 115 ms
100,436 KB
testcase_25 AC 73 ms
71,300 KB
testcase_26 AC 72 ms
71,356 KB
testcase_27 AC 71 ms
71,192 KB
testcase_28 AC 70 ms
71,384 KB
testcase_29 AC 72 ms
71,392 KB
権限があれば一括ダウンロードができます

ソースコード

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 = 0
for a, b in zip(A, B):
    d = b - a
    if d < 0 or d & 1:
        print(-1)
        exit()
print(cnt)
    
0