結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー brthyyjpbrthyyjp
提出日時 2021-03-11 03:13:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 67,884 KB
最終ジャッジ日時 2024-04-20 20:11:08
合計ジャッジ時間 3,000 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
52,224 KB
testcase_01 AC 45 ms
51,968 KB
testcase_02 AC 42 ms
52,224 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 WA -
testcase_05 AC 44 ms
52,608 KB
testcase_06 AC 52 ms
60,544 KB
testcase_07 AC 42 ms
52,480 KB
testcase_08 AC 77 ms
65,152 KB
testcase_09 AC 75 ms
65,792 KB
testcase_10 AC 53 ms
60,136 KB
testcase_11 AC 52 ms
60,160 KB
testcase_12 AC 64 ms
64,640 KB
testcase_13 AC 64 ms
64,768 KB
testcase_14 AC 68 ms
65,280 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 72 ms
66,304 KB
testcase_19 WA -
testcase_20 AC 65 ms
65,152 KB
testcase_21 AC 66 ms
65,152 KB
testcase_22 WA -
testcase_23 AC 77 ms
65,536 KB
testcase_24 AC 76 ms
66,816 KB
testcase_25 AC 74 ms
65,920 KB
testcase_26 AC 75 ms
67,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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