結果

問題 No.3597 Queen Score Attack 2
コンテスト
ユーザー K2
提出日時 2026-07-24 23:16:05
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 498 ms / 2,000 ms
+ 255µs
コード長 316 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 235 ms
コンパイル使用メモリ 95,980 KB
実行使用メモリ 223,488 KB
最終ジャッジ日時 2026-07-24 23:16:17
合計ジャッジ時間 10,659 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

H, W, x, y, N = map(int, input().split())

dp = [0, -1 << 60]

for nx, ny, c in [map(int, input().split()) for _ in range(N)]:
    ndp = [dp[1] + c, max(dp)]
    if x == nx or y == ny or x + y == nx + ny or x - y == nx - ny:
        ndp[0] = max(ndp[0], dp[0] + c)
    x = nx
    y = ny
    dp = ndp

print(max(dp))
0