結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー tookunn_1213
提出日時 2017-03-24 23:40:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 593 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 41,628 KB
最終ジャッジ日時 2024-07-06 01:32:59
合計ジャッジ時間 3,707 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 1 TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

gx,gy,N,F = map(int,input().split())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
c = [0 for i in range(N)]
for i in range(N):
	x[i],y[i],c[i] = map(int,input().split())
ans = 10**9+7
q = [(0,0,0,0)]
while len(q) > 0:
	p = q.pop(0)
	if p[0] == gx and p[1] == gy:
		ans = min(ans,p[2])
		continue;
	for i in range(N):
		if p[3] >> i & 1:
			continue
		if p[0]+x[i]<=gx and p[1]+y[i]<=gy and p[2]+c[i] < ans:
			q.append((p[0]+x[i],p[1]+y[i],p[2]+c[i],p[3]|(1<<i)))
	if p[0]+1 <= gx:
		q.append((p[0]+1,p[1],p[2]+F,p[3]))
	if p[1]+1 <= gy:
		q.append((p[0],p[1]+1,p[2]+F,p[3]))
print(ans)
0