結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー tookunn_1213tookunn_1213
提出日時 2017-03-24 23:40:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 593 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,812 KB
実行使用メモリ 36,520 KB
最終ジャッジ日時 2023-09-20 05:24:58
合計ジャッジ時間 3,866 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,520 KB
testcase_01 AC 16 ms
8,252 KB
testcase_02 AC 19 ms
8,208 KB
testcase_03 AC 17 ms
8,256 KB
testcase_04 AC 19 ms
8,272 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

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