結果

問題 No.844 split game
ユーザー neko_the_shadow
提出日時 2019-07-07 18:36:44
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 447 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,512 KB
実行使用メモリ 765,184 KB
最終ジャッジ日時 2024-10-05 03:58:31
合計ジャッジ時間 7,166 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other MLE * 1 -- * 55
権限があれば一括ダウンロードができます

ソースコード

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