結果

問題 No.1120 Strange Teacher
ユーザー 👑 rin204rin204
提出日時 2022-07-04 16:43:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 1,000 ms
コード長 478 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 82,128 KB
実行使用メモリ 103,804 KB
最終ジャッジ日時 2024-05-08 06:10:47
合計ジャッジ時間 3,381 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,332 KB
testcase_01 AC 34 ms
52,304 KB
testcase_02 AC 38 ms
59,604 KB
testcase_03 AC 44 ms
65,216 KB
testcase_04 AC 84 ms
103,168 KB
testcase_05 AC 82 ms
103,492 KB
testcase_06 AC 85 ms
103,804 KB
testcase_07 AC 82 ms
103,276 KB
testcase_08 AC 82 ms
103,576 KB
testcase_09 AC 37 ms
52,852 KB
testcase_10 AC 77 ms
102,052 KB
testcase_11 AC 77 ms
101,872 KB
testcase_12 AC 77 ms
101,592 KB
testcase_13 AC 76 ms
101,408 KB
testcase_14 AC 74 ms
101,532 KB
testcase_15 AC 75 ms
101,392 KB
testcase_16 AC 80 ms
103,112 KB
testcase_17 AC 79 ms
103,144 KB
testcase_18 AC 35 ms
53,008 KB
testcase_19 AC 82 ms
100,464 KB
testcase_20 AC 34 ms
52,340 KB
testcase_21 AC 34 ms
52,484 KB
testcase_22 AC 35 ms
52,004 KB
testcase_23 AC 34 ms
52,484 KB
testcase_24 AC 79 ms
102,316 KB
testcase_25 AC 37 ms
53,476 KB
testcase_26 AC 35 ms
52,496 KB
testcase_27 AC 34 ms
51,936 KB
testcase_28 AC 37 ms
52,308 KB
testcase_29 AC 37 ms
53,184 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