結果

問題 No.472 平均順位
ユーザー nebukuro09nebukuro09
提出日時 2016-12-26 11:36:30
言語 D
(dmd 2.106.1)
結果
MLE  
実行時間 -
コード長 877 bytes
コンパイル時間 1,962 ms
コンパイル使用メモリ 155,916 KB
実行使用メモリ 303,644 KB
最終ジャッジ日時 2023-09-03 00:10:22
合計ジャッジ時間 5,240 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 6 ms
4,496 KB
testcase_09 AC 19 ms
10,840 KB
testcase_10 AC 13 ms
8,072 KB
testcase_11 AC 57 ms
35,548 KB
testcase_12 AC 42 ms
24,556 KB
testcase_13 AC 141 ms
83,708 KB
testcase_14 MLE -
testcase_15 AC 144 ms
84,336 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 40 ms
22,160 KB
testcase_19 AC 72 ms
42,748 KB
権限があれば一括ダウンロードができます

ソースコード

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