結果

問題 No.2648 [Cherry 6th Tune D] 一次元の馬
ユーザー noriocnorioc
提出日時 2024-02-23 22:44:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 374 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 82,012 KB
実行使用メモリ 107,388 KB
最終ジャッジ日時 2024-09-29 07:51:09
合計ジャッジ時間 6,328 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import pairwise


def f(p, q, d) -> int:
    assert p > q
    return d // (p - q) + 1


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    t = 0
    for i, (a, b) in enumerate(pairwise(A), 1):
        x = a + i * t
        y = b + (i+1) * t
        if y <= x:
            t += f(i+1, i, x-y)

    print(t)


T = int(input())
for _ in range(T):
    solve()
0