結果

問題 No.844 split game
ユーザー tamato
提出日時 2020-02-25 23:06:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 90,496 KB
最終ジャッジ日時 2024-10-13 14:38:35
合計ジャッジ時間 12,106 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.buffer.readline

    N, M, x = map(int, input().split())
    info = [None] * M
    for i in range(M):
        info[i] = tuple(map(int, input().split()))
    info.sort(key=lambda e: e[1])
    info.sort(key=lambda e: e[0])

    dp = [-x] * (N+2)
    dp[1] = 0
    for l, r, p in info:
        flg = int(r!=N)
        dp[r+1] = max(dp[r+1], dp[l] + p - x * flg)
    print(max(dp))


if __name__ == '__main__':
    main()
0