結果
| 問題 | No.844 split game | 
| コンテスト | |
| ユーザー |  ngtkana | 
| 提出日時 | 2020-03-29 17:38:18 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 73 ms / 2,000 ms | 
| コード長 | 705 bytes | 
| コンパイル時間 | 4,179 ms | 
| コンパイル使用メモリ | 198,552 KB | 
| 最終ジャッジ日時 | 2025-01-09 10:51:38 | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 56 | 
ソースコード
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
void cmx(lint&x,lint y){if(x<y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m,a;std::cin>>n>>m>>a;
    std::vector<std::vector<std::pair<lint,lint>>>g(n+1);
    while(m--){
        lint l,r,p;std::cin>>l>>r>>p;l--;
        g.at(l).emplace_back(r,p);
    }
    std::vector<lint>dp(n+1,-a);
    dp.at(0)=0;
    for(lint i=0,max=0;i<=n;i++){
        cmx(dp.at(i),max-a);
        for(auto&&[j,p]:g.at(i)){
            cmx(dp.at(j),dp.at(i)+p-a);
        }
        cmx(max,dp.at(i));
    }
    std::cout<<dp.at(n)+a<<'\n';
}
            
            
            
        