結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
![]() |
提出日時 | 2024-12-30 20:11:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 534 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 72,832 KB |
最終ジャッジ日時 | 2024-12-30 20:11:40 |
合計ジャッジ時間 | 2,921 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
Gx, Gy, N, F = map(int, input().split())XYC = [list(map(int, input().split())) for _ in range(N)]INF = 10 ** 10dp = [[INF] * (Gy + 1) for _ in range(Gx + 1)]dp[0][0] = 0ans = (Gx + Gy) * Ffor x, y, c in XYC:for i in reversed(range(Gx - x + 1)):for j in reversed(range(Gy - y + 1)):if dp[i][j] != INF:if dp[i + x][j + y] > dp[i][j] + c:dp[i + x][j + y] = dp[i][j] + cans = min(ans, dp[i + x][j + y] + (Gx - i - x + Gy - j - y) * F)print(ans)