結果

問題 No.1120 Strange Teacher
ユーザー rlangevinrlangevin
提出日時 2023-03-30 12:35:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 631 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 81,628 KB
実行使用メモリ 103,212 KB
最終ジャッジ日時 2023-10-21 23:12:56
合計ジャッジ時間 5,027 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,396 KB
testcase_01 AC 36 ms
53,396 KB
testcase_02 AC 38 ms
59,396 KB
testcase_03 AC 44 ms
66,216 KB
testcase_04 AC 84 ms
102,948 KB
testcase_05 AC 77 ms
102,948 KB
testcase_06 AC 78 ms
102,956 KB
testcase_07 AC 78 ms
102,948 KB
testcase_08 AC 79 ms
102,948 KB
testcase_09 AC 34 ms
53,396 KB
testcase_10 AC 84 ms
103,212 KB
testcase_11 AC 81 ms
103,212 KB
testcase_12 AC 78 ms
103,212 KB
testcase_13 AC 79 ms
102,948 KB
testcase_14 AC 79 ms
102,948 KB
testcase_15 AC 78 ms
102,948 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 33 ms
53,396 KB
testcase_19 AC 80 ms
100,260 KB
testcase_20 AC 34 ms
53,396 KB
testcase_21 AC 34 ms
53,396 KB
testcase_22 AC 34 ms
53,396 KB
testcase_23 AC 35 ms
53,396 KB
testcase_24 AC 77 ms
102,520 KB
testcase_25 AC 34 ms
53,396 KB
testcase_26 WA -
testcase_27 AC 33 ms
53,396 KB
testcase_28 AC 33 ms
53,396 KB
testcase_29 AC 32 ms
53,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

up = 0
maxv = 0
for i in range(N):
    maxv = max(maxv, B[i] - A[i])
    up += (B[i] > A[i])

if up >= 2:
    print(-1)
    exit()

if N == 2:
    if sum(A) == sum(B):
        print(maxv)
    else:
        print(-1)
else:
    for i in range(N):
        if B[i] > A[i]:
            A[i] += maxv
        else:
            A[i] -= maxv

    S = 0
    for i in range(N):
        S += A[i] - B[i]
        if B[i] > A[i]:
            print(-1)
            exit()
    if S % (N - 2) == 0:
        print(S//(N-2) + maxv)
    else:
        print(-1)
0