結果

問題 No.1120 Strange Teacher
ユーザー stngstng
提出日時 2022-09-04 17:42:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 82,040 KB
実行使用メモリ 92,908 KB
最終ジャッジ日時 2024-04-29 17:55:38
合計ジャッジ時間 4,107 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 35 ms
51,840 KB
testcase_10 AC 81 ms
91,648 KB
testcase_11 AC 83 ms
91,776 KB
testcase_12 AC 82 ms
91,776 KB
testcase_13 AC 80 ms
91,744 KB
testcase_14 AC 78 ms
91,520 KB
testcase_15 AC 77 ms
90,752 KB
testcase_16 AC 85 ms
92,072 KB
testcase_17 AC 73 ms
90,716 KB
testcase_18 AC 36 ms
51,456 KB
testcase_19 AC 76 ms
92,908 KB
testcase_20 AC 40 ms
51,968 KB
testcase_21 AC 38 ms
52,224 KB
testcase_22 AC 38 ms
51,456 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 33 ms
52,224 KB
testcase_26 AC 34 ms
51,712 KB
testcase_27 AC 34 ms
51,712 KB
testcase_28 AC 35 ms
51,712 KB
testcase_29 AC 36 ms
51,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

li = [0]*n
ans = 0
for i in range(n):
    li[i] = b[i]-a[i]

li.sort(reverse=True)
if li[0] != -li[1]:
    print(-1)
    exit()
else:
    ans = li[0]
    now = -li[0]

for i in range(2,n):
    if now == -li[i]:
        continue
    elif abs(now-li[i]) % i == 0:
        ans += abs(now-li[i])
        now = -li[i]
    else:
        print(-1)
        exit()

print(ans)
0