結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー maspymaspy
提出日時 2020-02-26 12:40:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 540 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,480 KB
最終ジャッジ日時 2024-04-21 16:20:52
合計ジャッジ時間 15,967 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 531 ms
44,228 KB
testcase_01 AC 529 ms
44,232 KB
testcase_02 AC 532 ms
43,844 KB
testcase_03 AC 528 ms
44,356 KB
testcase_04 AC 531 ms
44,352 KB
testcase_05 AC 531 ms
44,096 KB
testcase_06 AC 534 ms
43,972 KB
testcase_07 AC 534 ms
43,840 KB
testcase_08 AC 531 ms
44,096 KB
testcase_09 AC 526 ms
43,840 KB
testcase_10 AC 535 ms
44,272 KB
testcase_11 AC 530 ms
44,352 KB
testcase_12 AC 527 ms
43,976 KB
testcase_13 AC 530 ms
43,968 KB
testcase_14 AC 523 ms
44,100 KB
testcase_15 AC 534 ms
44,480 KB
testcase_16 AC 536 ms
44,360 KB
testcase_17 AC 540 ms
43,972 KB
testcase_18 AC 530 ms
44,356 KB
testcase_19 AC 530 ms
44,096 KB
testcase_20 AC 529 ms
44,356 KB
testcase_21 AC 531 ms
44,348 KB
testcase_22 AC 531 ms
43,968 KB
testcase_23 AC 528 ms
44,232 KB
testcase_24 AC 527 ms
44,096 KB
testcase_25 AC 537 ms
43,972 KB
testcase_26 AC 536 ms
44,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
import numpy as np

# %%
Gx, Gy, N, F = map(int, readline().split())
m = map(int, read().split())
XYC = tuple(zip(m, m, m))


# %%
INF = 10 ** 16
dp = np.full((Gx + 1, Gy + 1), INF, np.int64)
dp[0, 0] = 0


# %%
for x, y, c in XYC:
    np.minimum(
        dp[x: Gx + 1, y: Gy + 1], dp[0: Gx + 1 - x, 0: Gy + 1 - y] + c,
        out=dp[x:Gx + 1, y:Gy + 1])

# %%
dp += F * (np.arange(Gx + 1)[::-1][:, None] + np.arange(Gy + 1)[::-1][None, :])
answer = dp.min()
print(answer)
0