結果

問題 No.1478 Simple Sugoroku
コンテスト
ユーザー LyricalMaestro
提出日時 2026-01-08 23:57:04
言語 PyPy3
(7.3.17)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 637 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 206 ms
コンパイル使用メモリ 82,708 KB
実行使用メモリ 90,844 KB
最終ジャッジ日時 2026-01-08 23:57:17
合計ジャッジ時間 5,304 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/1478

def main():
    N, M = map(int, input().split())

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


    exp = [0] * M
    cum_exp = [0] * M
    cum_e = 0
    for i in reversed(range(M)):
        e1 = N - B[i]
        if i == M - 1:
            exp[i] = e1
        else:
            r = (i + 1) / M
            ans = 1 + cum_exp[i + 1] / M
            ans *= 1 / (1 - r)
            exp[i] = min(exp[i + 1] + B[i + 1] - B[i], ans)

        cum_e += exp[i]
        cum_exp[i] = cum_e

    
    answer = B[0] - 1 + exp[0]
    print(answer)






        














if __name__ == "__main__":
    main()
0