結果

問題 No.844 split game
ユーザー neko_the_shadow
提出日時 2019-07-07 18:33:42
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 447 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 32,272 KB
最終ジャッジ日時 2024-10-05 03:48:08
合計ジャッジ時間 10,578 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20 RE * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections, functools, sys

sys.setrecursionlimit(2 ** 31 - 1)

n, m, a = map(int, input().split())
d = collections.defaultdict(int)
for _ in range(m):
    l, r, p = map(int, input().split())
    d[(l - 1, r)] = p

@functools.lru_cache(maxsize=None)
def f(current):
    ans = d[(current, n)] # 線を引かない場合
    for nxt in range(current + 1, n):
        ans = max(ans, f(nxt) + d[(current, nxt)] - a)
    return ans

print(f(0))
0