結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー lllllll88938494lllllll88938494
提出日時 2022-09-14 11:54:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 893 bytes
コンパイル時間 412 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 82,732 KB
最終ジャッジ日時 2023-08-21 12:05:00
合計ジャッジ時間 5,284 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 70 ms
71,332 KB
testcase_02 WA -
testcase_03 AC 72 ms
70,984 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 81 ms
75,764 KB
testcase_07 AC 71 ms
71,240 KB
testcase_08 WA -
testcase_09 AC 158 ms
82,572 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 115 ms
77,580 KB
testcase_13 AC 128 ms
78,084 KB
testcase_14 AC 128 ms
78,376 KB
testcase_15 AC 129 ms
77,696 KB
testcase_16 AC 132 ms
77,964 KB
testcase_17 AC 142 ms
78,948 KB
testcase_18 AC 140 ms
78,628 KB
testcase_19 WA -
testcase_20 AC 133 ms
77,920 KB
testcase_21 AC 125 ms
77,296 KB
testcase_22 AC 180 ms
82,732 KB
testcase_23 WA -
testcase_24 AC 175 ms
82,580 KB
testcase_25 AC 174 ms
82,596 KB
testcase_26 AC 178 ms
82,636 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+1)]
dp[0][0][0] = 0

for w in range(n+1):
    for i in range(gx+1):
        for j in range(gy+1):
            if dp[w][i][j] == inf:
                continue
            if w+1 < n+1:
                dp[w+1][i][j] = min(dp[w+1][i][j],dp[w][i][j])
            
            x,y,c=wa[w][0],wa[w][1],wa[w][2]
            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 i < i+x <=gx and j < j+y <=gy and w+1 < n+1:
                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+1):
    ans=min(ans,dp[i][gx][gy])
print(ans)
            
            
0