#include #include #include #include #include #include using namespace std; #define int long long #define rep(i,n) for(int i = 0; i < (n); i++) #define endl "\n" const long long INF = (long long)1e18; const long long MOD = (long long)1e9 + 7; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} #define MAX 110000 vector> num[MAX]; signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout<>N>>M>>A; for(int i = 0; i < M; i++){ cin>>l>>r>>p; num[r].push_back(make_pair(l-1, p)); } for(int i = 1; i <= N; i++){ if(N == i){ int max_ = -INF; max_ = max(max_, dp[i-1][1]); max_ = max(max_, dp[i-1][0]); dp[i][0] = max(0ll,max(dp[i-1][1], dp[i-1][0])); for(int j = 0; j < num[i].size(); j++){ max_ = max(dp[num[i][j].first][0] - A + num[i][j].second, max_); max_ = max(dp[num[i][j].first][1] + num[i][j].second, max_); // cout<