結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
|
提出日時 | 2017-03-24 22:48:26 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 1,068 bytes |
コンパイル時間 | 723 ms |
コンパイル使用メモリ | 121,644 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 18:32:15 |
合計ジャッジ時間 | 1,689 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
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.string; alias Tuple!(int, "x", int, "y", int, "c") Crystal; void main() { auto s = readln.split.map!(to!int); auto Gx = s[0]; auto Gy = s[1]; auto N = s[2]; auto F = s[3]; auto C = new Crystal[](N); foreach (i; 0..N) { s = readln.split.map!(to!int); C[i] = Crystal(s[0], s[1], s[2]); } auto dp = new int[][][](N+1, Gx+1, Gy+1); foreach (x; 0..Gx+1) { foreach (y; 0..Gy+1) { dp[0][x][y] = (x + y) * F; } } foreach (i; 0..N) { foreach (x; 0..Gx+1) { foreach (y; 0..Gy+1) { dp[i+1][x][y] = dp[i][x][y]; if (x - C[i].x < 0 || y - C[i].y < 0) continue; dp[i+1][x][y] = min(dp[i][x][y], dp[i][x-C[i].x][y-C[i].y] + C[i].c); } } } dp[N][Gx][Gy].writeln; }