結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー daleksprinterdaleksprinter
提出日時 2018-08-27 00:03:32
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 567 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 6,484 KB
実行使用メモリ 6,396 KB
最終ジャッジ日時 2023-09-13 19:28:12
合計ジャッジ時間 2,572 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,972 KB
testcase_01 AC 11 ms
5,904 KB
testcase_02 AC 11 ms
5,904 KB
testcase_03 AC 11 ms
5,932 KB
testcase_04 WA -
testcase_05 AC 11 ms
5,900 KB
testcase_06 AC 19 ms
6,136 KB
testcase_07 AC 11 ms
5,900 KB
testcase_08 AC 138 ms
6,220 KB
testcase_09 AC 138 ms
5,972 KB
testcase_10 AC 14 ms
6,060 KB
testcase_11 AC 14 ms
5,988 KB
testcase_12 AC 19 ms
5,848 KB
testcase_13 AC 24 ms
5,852 KB
testcase_14 AC 34 ms
5,968 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 36 ms
5,876 KB
testcase_19 WA -
testcase_20 AC 29 ms
6,084 KB
testcase_21 AC 18 ms
5,992 KB
testcase_22 WA -
testcase_23 AC 143 ms
6,344 KB
testcase_24 AC 132 ms
6,396 KB
testcase_25 AC 131 ms
6,172 KB
testcase_26 AC 133 ms
6,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

gx, gy, n, f = map(int,raw_input().split())

inf = float("inf")
dp = [[inf for i in range(gx+1)] for i in range(gy+1)]; dp[0][0] = 0
arr = [map(int,raw_input().split()) for i in range(n)]

for tx, ty,cost in arr:
	for y in range(gy+1):
		for x in range(gx+1):
			dx = x + tx; dy = y + ty

			if dp[y][x] != inf and dx < gx + 1 and dy < gy + 1 :
				dp[dy][dx] = min(dp[dy][dx], dp[y][x] + cost)

for i in range(gy + 1):
	for j in range(gx + 1):
		dp[i][j] = min(dp[i][j], (dp[i-1][j] + f) if i-1 > -1 else inf, (dp[i][j-1] + f) if j-1 > -1 else inf)

print dp[gy][gx]
0