結果

問題 No.1120 Strange Teacher
ユーザー YukikazariYukikazari
提出日時 2020-07-22 22:50:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 572 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 23,900 KB
最終ジャッジ日時 2023-09-05 03:03:20
合計ジャッジ時間 4,109 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 127 ms
23,736 KB
testcase_05 AC 119 ms
23,556 KB
testcase_06 AC 106 ms
23,688 KB
testcase_07 AC 111 ms
23,568 KB
testcase_08 AC 105 ms
23,564 KB
testcase_09 AC 16 ms
7,828 KB
testcase_10 AC 155 ms
23,660 KB
testcase_11 AC 154 ms
23,900 KB
testcase_12 AC 158 ms
23,728 KB
testcase_13 AC 138 ms
23,736 KB
testcase_14 AC 131 ms
23,560 KB
testcase_15 AC 108 ms
23,620 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 16 ms
7,804 KB
testcase_19 AC 103 ms
23,880 KB
testcase_20 AC 15 ms
7,876 KB
testcase_21 AC 16 ms
7,796 KB
testcase_22 AC 16 ms
7,876 KB
testcase_23 AC 15 ms
7,964 KB
testcase_24 AC 99 ms
20,760 KB
testcase_25 AC 16 ms
7,804 KB
testcase_26 AC 16 ms
7,884 KB
testcase_27 AC 15 ms
7,976 KB
testcase_28 AC 16 ms
7,844 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

diff = []

for i in range(N):
    t = B[i] - A[i]

    diff.append(t)

diff.sort()

t = diff[0]
res = 0.0

for obj in diff:
    if obj == t:
        pass
    else:
        res += (abs(t) + obj) / 2

if res.is_integer():
    r = int(res)
    if abs(t) == r:
        print(r)
    elif r == 0 and abs(t) % (N-2) == 0:
        print((abs(t) // (N - 2)) * N)
    elif (r - abs(t)) % (N - 2) == 0:
        print(r + (r - abs(t)) // (N - 2))
    else:
        print(-1)
else:
    print(-1)
0