結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 6 ms
4,380 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 6 ms
4,640 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 3 ms
4,384 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 5 ms
5,156 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 20 ms
7,520 KB
testcase_37 WA -
testcase_38 AC 163 ms
35,880 KB
testcase_39 AC 168 ms
36,592 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

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; 1..n+1)
    dp[i][0][0] = [0];

  foreach (i; 1..n+1)
    foreach (j; 1..k+1)
      foreach (e; 1..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