結果

問題 No.496 ワープクリスタル (給料日前編)
コンテスト
ユーザー brthyyjp
提出日時 2021-03-11 03:13:49
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 583 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 240 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 66,944 KB
最終ジャッジ日時 2026-04-29 21:25:24
合計ジャッジ時間 2,697 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

gx, gy, n, f = map(int, input().split())
XYC = []
for i in range(n):
    x, y, c = map(int, input().split())
    XYC.append((x, y, c))

INF = 10**18
dp = [[INF]*(gx+1) for i in range(gy+1)]
dp[0][0] = 0
for i in range(gy+1):
    for j in range(gx+1):
        for di, dj in (1, 0), (0, 1):
            ni, nj = i+di, j+dj
            if 0 <= ni <= gy and 0 <= nj <= gx:
                dp[ni][nj] = min(dp[ni][nj], dp[i][j]+f)
        for x, y, c in XYC:
            if 0 <= i+y <= gy and 0 <= j+x <= gx:
                dp[i+y][j+x] = min(dp[i+y][j+x], dp[i][j]+c)
print(dp[gy][gx])
0