結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー 👑 rin204rin204
提出日時 2022-07-05 16:36:09
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 439 bytes
コンパイル時間 1,536 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 76,380 KB
最終ジャッジ日時 2023-08-22 05:11:02
合計ジャッジ時間 3,964 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,328 KB
testcase_01 AC 74 ms
71,376 KB
testcase_02 AC 73 ms
71,096 KB
testcase_03 AC 74 ms
71,436 KB
testcase_04 AC 78 ms
71,432 KB
testcase_05 AC 74 ms
71,336 KB
testcase_06 AC 77 ms
75,348 KB
testcase_07 AC 73 ms
71,336 KB
testcase_08 AC 97 ms
76,380 KB
testcase_09 AC 95 ms
76,272 KB
testcase_10 AC 80 ms
76,160 KB
testcase_11 AC 79 ms
75,652 KB
testcase_12 AC 81 ms
75,656 KB
testcase_13 AC 85 ms
76,152 KB
testcase_14 AC 84 ms
76,200 KB
testcase_15 AC 81 ms
75,996 KB
testcase_16 AC 83 ms
76,144 KB
testcase_17 AC 85 ms
76,144 KB
testcase_18 AC 84 ms
76,180 KB
testcase_19 AC 81 ms
76,152 KB
testcase_20 AC 85 ms
76,328 KB
testcase_21 AC 81 ms
76,328 KB
testcase_22 AC 88 ms
76,272 KB
testcase_23 AC 88 ms
76,264 KB
testcase_24 AC 86 ms
76,336 KB
testcase_25 AC 89 ms
76,196 KB
testcase_26 AC 89 ms
75,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

gx, gy, n, f = map(int, input().split())
dp = [[1 << 30] * (gy + 1) for _ in range(gx + 1)]
dp[0][0] = 0
for _ in range(n):
    x, y, c = map(int, input().split())
    for xx in range(gx, x - 1, -1):
        for yy in range(gy, y - 1, -1):
            dp[xx][yy] = min(dp[xx][yy], dp[xx - x][yy - y] + c)

ans = 1 << 30
for x in range(gx + 1):
    for y in range(gy + 1):
        ans = min(ans, dp[x][y] + (gx - x + gy - y) * f)
print(ans)
0