結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー te-shte-sh
提出日時 2017-12-25 11:17:34
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 766 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 85,948 KB
実行使用メモリ 6,724 KB
最終ジャッジ日時 2023-09-03 17:46:57
合計ジャッジ時間 2,174 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 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,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 7 ms
6,660 KB
testcase_09 AC 7 ms
6,400 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 6 ms
5,436 KB
testcase_24 AC 6 ms
6,724 KB
testcase_25 AC 5 ms
6,264 KB
testcase_26 AC 6 ms
6,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main()
{
  auto rd = readln.split.to!(int[]), gx = rd[0], gy = rd[1], n = rd[2], f = rd[3];
  struct Crystal { int x, y, c; }
  auto c = new Crystal[](n);
  foreach (i; 0..n) {
    auto rd2 = readln.split.to!(int[]), xi = rd2[0], yi = rd2[1], ci = rd2[2];
    c[i] = Crystal(xi, yi, ci);
  }

  auto dp = new int[][][](n+1, gy+1, gx+1);
  foreach (y; 0..gy+1)
    foreach (x; 0..gx+1)
      dp[0][y][x] = f*(x+y);

  foreach (i; 0..n) {
    foreach (y; 0..gy+1) dp[i+1][y][] = dp[i][y][];
    foreach (y; 0..gy+1)
      foreach (x; 0..gx+1)
        if (x >= c[i].x && y >= c[i].y)
          dp[i+1][y][x] = min(dp[i][y][x], dp[i][y-c[i].y][x-c[i].x] + c[i].c);
  }

  writeln(dp[n][gy][gx]);
}
0