結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー daleksprinterdaleksprinter
提出日時 2018-08-26 23:49:31
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 678 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 6,532 KB
実行使用メモリ 6,248 KB
最終ジャッジ日時 2023-09-13 19:27:38
合計ジャッジ時間 2,829 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,936 KB
testcase_01 AC 11 ms
5,956 KB
testcase_02 AC 12 ms
5,936 KB
testcase_03 AC 10 ms
5,988 KB
testcase_04 WA -
testcase_05 AC 11 ms
5,900 KB
testcase_06 AC 18 ms
6,248 KB
testcase_07 AC 11 ms
5,844 KB
testcase_08 AC 181 ms
6,152 KB
testcase_09 AC 180 ms
5,980 KB
testcase_10 AC 13 ms
5,824 KB
testcase_11 AC 14 ms
5,840 KB
testcase_12 AC 18 ms
5,936 KB
testcase_13 AC 23 ms
5,960 KB
testcase_14 AC 35 ms
5,976 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 36 ms
6,108 KB
testcase_19 WA -
testcase_20 AC 29 ms
6,168 KB
testcase_21 AC 18 ms
5,956 KB
testcase_22 WA -
testcase_23 AC 139 ms
6,224 KB
testcase_24 AC 134 ms
6,244 KB
testcase_25 AC 132 ms
6,208 KB
testcase_26 AC 137 ms
6,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

inf = float("inf")
dp = [[inf for i in range(gx+3)] for i in range(gy+3)]
dp[0][0] = 0

arr = [map(int,raw_input().split()) for i in range(n)]

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

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

for i in range(1,gx+1):
	dp[0][i] = min(dp[0][i-1] + f, dp[0][i])

for i in range(1,gy+1):
	dp[i][0] = min(dp[i-1][0] + f, dp[i][0])

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

print dp[gy][gx]
0