結果

問題 No.844 split game
コンテスト
ユーザー neko_the_shadow
提出日時 2019-07-07 18:36:44
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
MLE  
実行時間 -
コード長 447 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 357 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 766,708 KB
最終ジャッジ日時 2026-04-20 19:02:11
合計ジャッジ時間 7,120 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other MLE * 1 -- * 55
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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