結果

問題 No.472 平均順位
ユーザー terrafarmterrafarm
提出日時 2020-12-14 07:30:31
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,000 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 130,216 KB
最終ジャッジ日時 2023-10-20 04:45:25
合計ジャッジ時間 8,446 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
84,212 KB
testcase_01 AC 97 ms
79,864 KB
testcase_02 AC 94 ms
79,864 KB
testcase_03 AC 98 ms
79,860 KB
testcase_04 AC 100 ms
80,500 KB
testcase_05 AC 103 ms
79,868 KB
testcase_06 AC 100 ms
80,496 KB
testcase_07 AC 101 ms
80,496 KB
testcase_08 AC 142 ms
81,044 KB
testcase_09 AC 287 ms
81,352 KB
testcase_10 AC 225 ms
81,068 KB
testcase_11 AC 667 ms
83,092 KB
testcase_12 AC 516 ms
82,024 KB
testcase_13 AC 1,720 ms
86,500 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import logging
import sys
from inspect import currentframe

# 一つ前の配列だけ持っていれば十分
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

logging.basicConfig(level=logging.DEBUG)


def dbg(*args):
    id2names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    logging.debug(
        ", ".join(id2names.get(id(arg), "???") + " = " + repr(arg) for arg in args)
    )


def main():

    INF = 10 ** 10
    n, p = map(int, input().split())
    dp = [[INF] * (p + 1) for _ in range(2)]
    dp[0][0] = 0
    for i in range(n):
        l = list(map(int, input().split()))
        l.append(1)
        for j in range(p + 1):
            for k in range(4):
                if j + k <= p:
                    dp[1][j + k] = min(dp[1][j + k], dp[0][j] + l[k])
        # for j in range(p + 1):
        #     dp[0][j] = dp[1][j]
        dp[0] = dp[1][:]
        dp[1] = [INF] * (p + 1)
    ans = dp[0][p] / n
    print(ans)


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