結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,032 KB
testcase_01 AC 12 ms
5,900 KB
testcase_02 AC 11 ms
5,992 KB
testcase_03 AC 11 ms
5,900 KB
testcase_04 WA -
testcase_05 AC 11 ms
5,904 KB
testcase_06 AC 19 ms
6,160 KB
testcase_07 AC 11 ms
5,932 KB
testcase_08 AC 347 ms
6,188 KB
testcase_09 AC 348 ms
5,940 KB
testcase_10 AC 14 ms
6,108 KB
testcase_11 AC 15 ms
5,952 KB
testcase_12 AC 21 ms
5,896 KB
testcase_13 AC 29 ms
6,080 KB
testcase_14 AC 45 ms
5,844 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 47 ms
5,900 KB
testcase_19 WA -
testcase_20 AC 36 ms
6,060 KB
testcase_21 AC 21 ms
5,948 KB
testcase_22 WA -
testcase_23 AC 193 ms
6,368 KB
testcase_24 AC 187 ms
6,192 KB
testcase_25 AC 180 ms
6,208 KB
testcase_26 AC 191 ms
6,260 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 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)


for x,y,cost in arr:
	for i in range(gy + 1):
		for j in range(gx + 1):
			dx = j + x; dy = i + y
			if -1 < dx < gx + 1 and -1 < dy < gy + 1 :
				dp[dy][dx] = min(dp[i][j] + cost, dp[dy][dx])

print dp[gy][gx]
0