結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー titiatitia
提出日時 2023-06-27 04:54:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 76,564 KB
最終ジャッジ日時 2023-09-17 01:01:09
合計ジャッジ時間 3,823 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,536 KB
testcase_01 AC 72 ms
71,280 KB
testcase_02 AC 73 ms
71,376 KB
testcase_03 AC 71 ms
71,116 KB
testcase_04 AC 72 ms
71,248 KB
testcase_05 AC 71 ms
71,336 KB
testcase_06 AC 76 ms
75,904 KB
testcase_07 AC 72 ms
71,376 KB
testcase_08 AC 89 ms
76,452 KB
testcase_09 AC 90 ms
76,452 KB
testcase_10 AC 81 ms
76,404 KB
testcase_11 AC 78 ms
75,884 KB
testcase_12 AC 85 ms
76,196 KB
testcase_13 AC 87 ms
76,256 KB
testcase_14 AC 82 ms
76,448 KB
testcase_15 AC 82 ms
76,564 KB
testcase_16 AC 82 ms
76,292 KB
testcase_17 AC 84 ms
76,408 KB
testcase_18 AC 80 ms
76,384 KB
testcase_19 AC 82 ms
76,168 KB
testcase_20 AC 81 ms
76,188 KB
testcase_21 AC 82 ms
76,468 KB
testcase_22 AC 87 ms
76,392 KB
testcase_23 AC 90 ms
76,340 KB
testcase_24 AC 88 ms
76,480 KB
testcase_25 AC 87 ms
76,524 KB
testcase_26 AC 90 ms
76,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Gx,Gy,N,F=map(int,input().split())

C=[list(map(int,input().split())) for i in range(N)]

DP=dict()
DP=[[1<<60]*(Gy+1) for i in range(Gx+1)]
DP[0][0]=0

for x,y,c in C:
    for i in range(Gx,-1,-1):
        for j in range(Gy,-1,-1):
            if DP[i][j]==1<<60:
                continue
            if i+x<Gx+1 and j+y<Gy+1:
                DP[i+x][j+y]=min(DP[i+x][j+y],DP[i][j]+c)

ANS=1<<60

for i in range(Gx+1):
    for j in range(Gy+1):
        ANS=min(ANS,DP[i][j]+(Gx-i)*F+(Gy-j)*F)

print(ANS)
0