結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー lllllll88938494lllllll88938494
提出日時 2022-09-14 12:08:45
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 953 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 86,788 KB
実行使用メモリ 83,520 KB
最終ジャッジ日時 2023-08-21 12:14:54
合計ジャッジ時間 4,795 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,456 KB
testcase_01 AC 71 ms
71,088 KB
testcase_02 AC 71 ms
71,248 KB
testcase_03 AC 71 ms
71,136 KB
testcase_04 AC 69 ms
71,396 KB
testcase_05 AC 74 ms
71,140 KB
testcase_06 AC 91 ms
76,420 KB
testcase_07 AC 71 ms
71,364 KB
testcase_08 AC 203 ms
83,520 KB
testcase_09 AC 184 ms
82,780 KB
testcase_10 AC 93 ms
76,928 KB
testcase_11 AC 97 ms
76,508 KB
testcase_12 AC 119 ms
77,536 KB
testcase_13 AC 130 ms
78,208 KB
testcase_14 AC 129 ms
78,364 KB
testcase_15 AC 132 ms
77,916 KB
testcase_16 AC 132 ms
78,248 KB
testcase_17 AC 139 ms
79,080 KB
testcase_18 AC 139 ms
78,688 KB
testcase_19 AC 136 ms
78,344 KB
testcase_20 AC 136 ms
78,280 KB
testcase_21 AC 124 ms
77,732 KB
testcase_22 AC 172 ms
82,596 KB
testcase_23 AC 174 ms
82,728 KB
testcase_24 AC 173 ms
83,128 KB
testcase_25 AC 170 ms
82,656 KB
testcase_26 AC 171 ms
82,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

gx,gy,n,f=map(int,input().split())
wa=[[0,0,0]]+[list(map(int,input().split())) for i in range(n)]
inf=10**8
dp=[[[inf]*(gy+1) for i in range(gx+1)] for i in range(n+2)]
dp[0][0][0] = 0

for w in range(n+2):
    for i in range(gx+1):
        for j in range(gy+1):
            if dp[w][i][j] == inf:
                continue
            if w+1 < n+2:
                dp[w+1][i][j] = min(dp[w+1][i][j],dp[w][i][j])
            
            if i + 1 <= gx:
                dp[w][i+1][j] = min(dp[w][i+1][j],dp[w][i][j]+f)
            if j + 1 <= gy:
                dp[w][i][j+1] = min(dp[w][i][j+1],dp[w][i][j]+f)

            if w+1 < n + 2:
                x,y,c=wa[w][0],wa[w][1],wa[w][2]
                if i <= i+x <=gx and j <= j+y <=gy:
                    dp[w+1][i+x][j+y] = min(dp[w+1][i+x][j+y],dp[w][i][j] + c)

ans=10**10
# for i in range(n+2):
#     ans=min(ans,dp[i][gx][gy])
# print(ans)


print(dp[n+1][gx][gy])
            
            
0