結果
| 問題 | No.496 ワープクリスタル (給料日前編) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-29 21:30:03 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 145 ms / 2,000 ms |
| + 233µs | |
| コード長 | 800 bytes |
| 記録 | |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 64,308 KB |
| 実行使用メモリ | 76,160 KB |
| 最終ジャッジ日時 | 2026-10-29 21:30:07 |
| 合計ジャッジ時間 | 4,019 ms |
|
ジャッジサーバーID (参考情報) |
judge7_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 |
ソースコード
INF = 1e18
from collections import defaultdict
def main():
Gx, Gy, N, F = map(int, input().split())
def check(x, y):
return 0 <= x <= Gx and 0 <= y <= Gy
dp = defaultdict(lambda: INF)
dp[(0, 0)] = 0
for i in range(N):
xi, yi, ci = map(int, input().split())
ndp = defaultdict(lambda: INF)
for k, v in dp.items():
x, y = k
# 不採用
ndp[(x, y)] = min(ndp[(x, y)], v)
nx, ny = x + xi, y + yi
if check(nx, ny):
ndp[(nx, ny)] = min(ndp[(nx, ny)], v + ci)
dp = ndp
ans = INF
for k, v in dp.items():
x, y = k
sub = ((Gx - x) + (Gy - y))*F + v
if sub < ans:
ans = sub
print(ans)
if __name__ == "__main__":
main()