結果

問題 No.115 遠足のおやつ
ユーザー te-shte-sh
提出日時 2017-01-30 12:12:29
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 165 ms / 5,000 ms
コード長 747 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 91,896 KB
実行使用メモリ 35,828 KB
最終ジャッジ日時 2023-09-03 01:01:18
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 6 ms
5,416 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 53 ms
20,912 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 5 ms
5,424 KB
testcase_10 AC 7 ms
4,700 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 35 ms
14,468 KB
testcase_16 AC 47 ms
18,772 KB
testcase_17 AC 13 ms
6,932 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 25 ms
8,852 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 22 ms
8,308 KB
testcase_25 AC 14 ms
7,480 KB
testcase_26 AC 6 ms
4,380 KB
testcase_27 AC 10 ms
5,492 KB
testcase_28 AC 6 ms
4,376 KB
testcase_29 AC 9 ms
4,956 KB
testcase_30 AC 22 ms
8,308 KB
testcase_31 AC 7 ms
4,932 KB
testcase_32 AC 38 ms
14,504 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 AC 52 ms
19,860 KB
testcase_35 AC 14 ms
6,680 KB
testcase_36 AC 20 ms
7,824 KB
testcase_37 AC 40 ms
14,744 KB
testcase_38 AC 162 ms
35,828 KB
testcase_39 AC 165 ms
35,228 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main()
{
  auto rd = readln.split.to!(int[]), n = rd[0], d = rd[1], k = rd[2];

  auto dp = new int[][][][](n+1, k+1, d+1);
  foreach (i; 0..n+1)
    dp[i][0][0] = [0];

  foreach (i; 1..n+1)
    foreach (j; 1..k+1)
      foreach (e; 0..d+1) {
        auto c1 = e >= i ? dp[i-1][j-1][e-i] ~ i : [i];
        auto c2 = dp[i-1][j][e];
        if (c1.front == 0) {
          if (!c2.empty)
            dp[i][j][e] = min(c1, c2);
          else
            dp[i][j][e] = c1;
        } else {
          if (!c2.empty)
            dp[i][j][e] = c2;
        }
      }

  auto r = dp[n][k][d];
  if (r.empty)
    writeln(-1);
  else
    writeln(r.drop(1).to!(string[]).join(" "));
}
0