結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー tabataba
提出日時 2017-04-03 04:54:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 396 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 91,988 KB
最終ジャッジ日時 2023-09-22 09:19:43
合計ジャッジ時間 5,148 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,044 KB
testcase_01 AC 70 ms
71,388 KB
testcase_02 AC 71 ms
71,276 KB
testcase_03 AC 70 ms
71,148 KB
testcase_04 AC 71 ms
71,152 KB
testcase_05 AC 71 ms
71,288 KB
testcase_06 AC 101 ms
76,660 KB
testcase_07 AC 75 ms
71,224 KB
testcase_08 AC 108 ms
77,296 KB
testcase_09 AC 396 ms
91,988 KB
testcase_10 AC 82 ms
76,468 KB
testcase_11 AC 83 ms
76,356 KB
testcase_12 AC 98 ms
76,768 KB
testcase_13 AC 113 ms
78,048 KB
testcase_14 AC 135 ms
79,960 KB
testcase_15 AC 108 ms
78,780 KB
testcase_16 AC 107 ms
77,476 KB
testcase_17 AC 112 ms
77,620 KB
testcase_18 AC 110 ms
78,544 KB
testcase_19 AC 119 ms
78,704 KB
testcase_20 AC 111 ms
79,764 KB
testcase_21 AC 105 ms
78,324 KB
testcase_22 AC 172 ms
80,684 KB
testcase_23 AC 177 ms
80,436 KB
testcase_24 AC 167 ms
80,568 KB
testcase_25 AC 155 ms
80,184 KB
testcase_26 AC 169 ms
82,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

gx,gy,n,f=map(int,input().split())
c=[list(map(int,input().split()))for _ in[0]*n]
gx+=1
gy+=1
d=[[1e99]*gx for _ in[0]*gy]
d[0][0]=0
def dp(x,y,u):
	for i in range(n):
		if u[i]:continue
		nx=x+c[i][0]
		ny=y+c[i][1]
		if nx<gx and ny<gy and d[y][x]+c[i][2]<d[ny][nx]:
			d[ny][nx]=d[y][x]+c[i][2]
			nu=u[:]
			nu[i]=True
			dp(nx,ny,nu)
	nx=x+1
	ny=y
	if nx<gx and ny<gy and d[y][x]+f<d[ny][nx]:
		d[ny][nx]=d[y][x]+f
		dp(nx,ny,u[:])
	nx=x
	ny=y+1
	if nx<gx and ny<gy and d[y][x]+f<d[ny][nx]:
		d[ny][nx]=d[y][x]+f
		dp(nx,ny,u[:])
dp(0,0,[False]*n)
print(d[-1][-1])
0