結果

問題 No.1120 Strange Teacher
ユーザー lloyzlloyz
提出日時 2023-05-14 00:08:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 1,043 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 101,476 KB
最終ジャッジ日時 2023-08-19 19:47:45
合計ジャッジ時間 7,281 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,348 KB
testcase_01 AC 68 ms
71,044 KB
testcase_02 AC 71 ms
75,852 KB
testcase_03 AC 75 ms
76,592 KB
testcase_04 AC 114 ms
101,176 KB
testcase_05 AC 114 ms
101,084 KB
testcase_06 AC 114 ms
101,008 KB
testcase_07 AC 115 ms
101,212 KB
testcase_08 AC 115 ms
101,140 KB
testcase_09 AC 68 ms
71,224 KB
testcase_10 AC 112 ms
101,084 KB
testcase_11 AC 112 ms
101,264 KB
testcase_12 AC 111 ms
101,160 KB
testcase_13 AC 112 ms
101,084 KB
testcase_14 AC 113 ms
101,204 KB
testcase_15 AC 113 ms
101,336 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 68 ms
71,224 KB
testcase_21 AC 67 ms
71,328 KB
testcase_22 AC 67 ms
71,232 KB
testcase_23 AC 67 ms
71,356 KB
testcase_24 AC 111 ms
100,328 KB
testcase_25 AC 70 ms
71,336 KB
testcase_26 AC 68 ms
71,348 KB
testcase_27 AC 68 ms
71,532 KB
testcase_28 AC 68 ms
71,196 KB
testcase_29 AC 67 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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)
    exit()
if sumD < 0 and abs(sumD) % (n - 2) == 0:
    cnt = abs(sumD) // (n - 2)
    res = 0
    for i in range(n):
        if (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