結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー tktk_snsn
提出日時 2021-03-20 12:03:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-20 21:03:53
合計ジャッジ時間 4,517 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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