結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,052 KB
testcase_01 AC 12 ms
5,996 KB
testcase_02 AC 12 ms
5,828 KB
testcase_03 AC 11 ms
5,992 KB
testcase_04 WA -
testcase_05 AC 11 ms
5,992 KB
testcase_06 AC 18 ms
6,220 KB
testcase_07 AC 11 ms
6,060 KB
testcase_08 AC 182 ms
6,168 KB
testcase_09 AC 180 ms
6,056 KB
testcase_10 AC 13 ms
5,828 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 AC 34 ms
6,120 KB
testcase_15 WA -
testcase_16 RE -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 AC 139 ms
6,140 KB
testcase_24 AC 135 ms
6,236 KB
testcase_25 AC 134 ms
6,204 KB
testcase_26 AC 137 ms
6,148 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 < gx + 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