結果

問題 No.3597 Queen Score Attack 2
コンテスト
ユーザー kidodesu
提出日時 2026-07-24 22:20:54
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 333 ms / 2,000 ms
+ 66µs
コード長 428 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,430 ms
コンパイル使用メモリ 95,840 KB
実行使用メモリ 84,736 KB
最終ジャッジ日時 2026-07-24 22:22:39
合計ジャッジ時間 7,972 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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 = [max(dp), max(dp)+c]
        else:
            dp = [max(dp), dp[0]+c]
        py, px = y, x
    return max(dp)

print(main())
0