結果

問題 No.472 平均順位
ユーザー nebukuro09nebukuro09
提出日時 2016-12-26 11:38:40
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 507 ms / 2,000 ms
コード長 906 bytes
コンパイル時間 1,988 ms
コンパイル使用メモリ 153,976 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 00:10:35
合計ジャッジ時間 4,812 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 16 ms
4,376 KB
testcase_10 AC 11 ms
4,380 KB
testcase_11 AC 46 ms
4,380 KB
testcase_12 AC 33 ms
4,380 KB
testcase_13 AC 116 ms
4,376 KB
testcase_14 AC 422 ms
4,380 KB
testcase_15 AC 116 ms
4,376 KB
testcase_16 AC 485 ms
4,380 KB
testcase_17 AC 507 ms
4,376 KB
testcase_18 AC 32 ms
4,380 KB
testcase_19 AC 57 ms
4,376 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[][](2, P+1);
    foreach (j; 0..P+1)
        dp[0][j] = A[0][min(j, 3)];

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

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