結果

問題 No.472 平均順位
ユーザー nebukuro09
提出日時 2016-12-26 11:36:30
言語 D
(dmd 2.109.1)
結果
MLE  
実行時間 -
コード長 877 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 155,420 KB
実行使用メモリ 303,204 KB
最終ジャッジ日時 2024-06-12 06:05:59
合計ジャッジ時間 5,189 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 MLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    int N, P;
    scanf("%d %d", &N, &P);

    auto A = new int[][](N, 4);
    foreach (i; 0..N) {
        scanf("%d %d %d", &A[i][0], &A[i][1], &A[i][2]);
        A[i][3] = 1;
    }

    auto dp = new int[][](N, P+1);
    foreach (j; 0..P+1)
        dp[0][j] = A[0][min(j, 3)];

    foreach (i; 1..N) {
        foreach (j; 0..P+1) {
            dp[i][j] = dp[i-1][j] + A[i][0];
            if (j >= 1) dp[i][j] = min(dp[i][j], dp[i-1][j-1] + A[i][1]);
            if (j >= 2) dp[i][j] = min(dp[i][j], dp[i-1][j-2] + A[i][2]);
            if (j >= 3) dp[i][j] = min(dp[i][j], dp[i-1][j-3] + A[i][3]);
        }
    }

    writefln("%.10f", dp[N-1][P] * 1.0L / N);
}
0