結果

問題 No.472 平均順位
ユーザー roarisroaris
提出日時 2019-12-16 15:44:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 652 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 86,660 KB
実行使用メモリ 79,524 KB
最終ジャッジ日時 2023-09-15 17:39:54
合計ジャッジ時間 13,669 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,376 KB
testcase_01 AC 74 ms
71,288 KB
testcase_02 AC 73 ms
71,460 KB
testcase_03 AC 73 ms
71,056 KB
testcase_04 AC 108 ms
76,880 KB
testcase_05 AC 73 ms
71,456 KB
testcase_06 AC 89 ms
76,120 KB
testcase_07 AC 123 ms
77,208 KB
testcase_08 AC 149 ms
78,192 KB
testcase_09 AC 224 ms
78,412 KB
testcase_10 AC 205 ms
78,756 KB
testcase_11 AC 399 ms
78,460 KB
testcase_12 AC 336 ms
78,824 KB
testcase_13 AC 837 ms
79,172 KB
testcase_14 TLE -
testcase_15 AC 861 ms
79,032 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 311 ms
78,800 KB
testcase_19 AC 482 ms
78,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, P = map(int, input().split())
abc = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[10**18]*(P+1) for _ in range(2)]
dp[0][0] = 0

for i in range(N):
    ai, bi, ci = abc[i]
    
    for j in range(P+1):
        dp[(i+1)&1][j] = 10**18
        
    for j in range(P+1):
        dp[(i+1)&1][j] = min(dp[(i+1)&1][j], dp[i&1][j]+ai)
        
        if j+1<=P:
            dp[(i+1)&1][j+1] = min(dp[(i+1)&1][j+1], dp[i&1][j]+bi)
        
        if j+2<=P:
            dp[(i+1)&1][j+2] = min(dp[(i+1)&1][j+2], dp[i&1][j]+ci)
        
        if j+3<=P:
            dp[(i+1)&1][j+3] = min(dp[(i+1)&1][j+3], dp[i&1][j]+1)

print(dp[N&1][P]/N)
0