結果

問題 No.472 平均順位
ユーザー te-shte-sh
提出日時 2017-12-12 15:21:45
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 974 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 1,869 ms
コンパイル使用メモリ 150,560 KB
実行使用メモリ 5,764 KB
最終ジャッジ日時 2023-09-03 17:30:21
合計ジャッジ時間 6,419 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 31 ms
4,376 KB
testcase_10 AC 19 ms
4,376 KB
testcase_11 AC 89 ms
4,376 KB
testcase_12 AC 61 ms
4,380 KB
testcase_13 AC 221 ms
5,764 KB
testcase_14 AC 818 ms
4,376 KB
testcase_15 AC 228 ms
4,380 KB
testcase_16 AC 957 ms
4,376 KB
testcase_17 AC 974 ms
4,376 KB
testcase_18 AC 60 ms
4,380 KB
testcase_19 AC 113 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), n = rd[0], p = rd[1];
  auto r = new int[][](n, 4);
  foreach (i; 0..n) r[i] = readln.split.to!(int[]) ~ 1;

  auto inf = 10^^9;
  auto dp = new int[](p+1), dp2 = new int[](p+1);
  dp[] = inf;
  dp[0] = 0;

  foreach (i; 0..n) {
    dp2[] = inf;
    foreach (j; 0..p+1)
      foreach (k; 0..4)
        if (j-k >= 0)
          dp2[j] = min(dp2[j], dp[j-k] + r[i][k]);
    dp[] = dp2[];
  }

  writefln("%.6f", dp[p].to!real / n);
}
0