結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー tktk_snsntktk_snsn
提出日時 2021-03-20 12:03:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-30 22:41:00
合計ジャッジ時間 4,592 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 30 ms
10,624 KB
testcase_04 WA -
testcase_05 AC 31 ms
10,624 KB
testcase_06 AC 38 ms
10,880 KB
testcase_07 AC 31 ms
10,624 KB
testcase_08 AC 553 ms
10,752 KB
testcase_09 AC 545 ms
10,752 KB
testcase_10 AC 35 ms
10,624 KB
testcase_11 AC 35 ms
10,624 KB
testcase_12 AC 42 ms
10,624 KB
testcase_13 AC 53 ms
10,624 KB
testcase_14 AC 74 ms
10,624 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 76 ms
10,624 KB
testcase_19 WA -
testcase_20 AC 62 ms
10,752 KB
testcase_21 AC 41 ms
10,752 KB
testcase_22 WA -
testcase_23 AC 276 ms
10,880 KB
testcase_24 AC 265 ms
10,752 KB
testcase_25 AC 248 ms
10,752 KB
testcase_26 AC 271 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
inf = 10**9

gx, gy, n, f = map(int, input().split())
H = gx + 1
W = gy + 1

dp = [inf] * (H * W)
dp[0] = 0
for _ in range(n):
    x, y, c = map(int, input().split())
    for i in range(H):
        for j in range(W):
            nx = x + i
            ny = y + j
            if nx < H and ny < W:
                to = nx * W + ny
                dp[to] = min(dp[to], dp[i*W+j] + c)

ans = inf
for i in range(H):
    for j in range(W):
        cost = f * (gx+gy-i-j)
        ans = min(ans, dp[i*W+j]+cost)
print(ans)
0