結果

問題 No.1120 Strange Teacher
ユーザー rlangevinrlangevin
提出日時 2023-03-30 12:37:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 642 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 81,492 KB
実行使用メモリ 103,244 KB
最終ジャッジ日時 2023-10-21 23:16:04
合計ジャッジ時間 3,818 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 37 ms
53,344 KB
testcase_10 AC 85 ms
103,244 KB
testcase_11 AC 85 ms
103,244 KB
testcase_12 AC 85 ms
103,184 KB
testcase_13 AC 83 ms
102,980 KB
testcase_14 AC 82 ms
102,980 KB
testcase_15 AC 81 ms
102,980 KB
testcase_16 AC 79 ms
102,980 KB
testcase_17 AC 80 ms
102,980 KB
testcase_18 AC 34 ms
53,344 KB
testcase_19 AC 86 ms
100,256 KB
testcase_20 AC 36 ms
53,344 KB
testcase_21 AC 35 ms
53,344 KB
testcase_22 AC 36 ms
53,344 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 35 ms
53,344 KB
testcase_26 AC 35 ms
53,344 KB
testcase_27 AC 35 ms
53,344 KB
testcase_28 AC 35 ms
53,344 KB
testcase_29 AC 37 ms
53,344 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 != 1 and A != B:
    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