結果

問題 No.3597 Queen Score Attack 2
コンテスト
ユーザー kidodesu
提出日時 2026-07-24 21:16:01
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 424 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 231 ms
コンパイル使用メモリ 95,984 KB
実行使用メモリ 84,864 KB
最終ジャッジ日時 2026-07-24 21:16:09
合計ジャッジ時間 8,033 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
    h, w, sy, sx, n = list(map(int, input().split()))
    py, px = sy-1, sx-1
    inf = 1<<60
    dp = [-inf, 0]
    for _ in range(n):
        y, x, c = list(map(int, input().split()))
        y, x = y-1, x-1
        if py == y or px == x or py-px == y-x or py+px == y+x:
            dp = [dp[1], max(dp)+c]
        else:
            dp = [dp[1], dp[0]+c]
        py, px = y, x
    return max(dp)

print(main())
0