結果

問題 No.1120 Strange Teacher
ユーザー stngstng
提出日時 2022-09-04 18:42:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 426 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 92,544 KB
最終ジャッジ日時 2024-04-29 18:44:50
合計ジャッジ時間 3,257 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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
51,456 KB
testcase_10 AC 94 ms
91,520 KB
testcase_11 AC 92 ms
91,136 KB
testcase_12 AC 96 ms
91,904 KB
testcase_13 AC 87 ms
91,904 KB
testcase_14 AC 87 ms
91,776 KB
testcase_15 AC 80 ms
90,752 KB
testcase_16 AC 88 ms
91,904 KB
testcase_17 AC 81 ms
90,880 KB
testcase_18 AC 36 ms
51,712 KB
testcase_19 AC 83 ms
92,544 KB
testcase_20 AC 38 ms
51,840 KB
testcase_21 AC 39 ms
51,968 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 38 ms
51,712 KB
testcase_28 AC 39 ms
51,456 KB
testcase_29 AC 40 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)
ans = li[0]
now = -li[0]

for i in range(1,n):
    #print(now,li[i],ans)
    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