Language: C++

#include <bits/stdc++.h>

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

struct edge {
	lli cost;
	lli to;
	edge(lli a, lli b) :to(a), cost(b) {};
};

struct val {
	set<lli> visited;
	lli pos;
	lli have;
	val(lli a, lli b) :pos(a), have(b) {};
};

int main() {
	lli N, M, P;
	cin >> N >> M >> P;
	vector<vector<edge>> graph(N);
	for (int i = 0; i < M; i++) {
		lli a, b, c;
		cin >> a >> b >> c;
		a--; b--; c-=P;
		graph[a].push_back(edge(b, c));
	}
	vector<bool> disable(N, false);
	for (int i = 0; i < N; i++) {
		queue<val> q;
		for (auto j : graph[i]) {
			q.push(val(j.to, j.cost));
		}
		while (!q.empty()) {
			auto now = q.front(); q.pop();
			if (now.pos == i) {
				if (now.have > 0) {
					disable[i] = true;
					break;
				}
				continue;
			}
			now.visited.insert(now.pos);
			for (auto j : graph[now.pos]) {
				if (now.visited.count(j.to) == 0) {
					auto cp = now;
					cp.have += j.cost;
					cp.pos = j.to;
					q.push(cp);
				}
			}
		}
	}
	stack<val> st;
	st.push(val(0, 0));
	lli ans = -1;
	

	while (!st.empty()) {
		auto now = st.top(); st.pop();
		if (now.pos == N - 1) {
			ans = max({ ans,0LL,now.have });
		}
		now.visited.insert(now.pos);
		for (auto i : graph[now.pos]) {
			if (now.visited.count(i.to) == 0 && !disable[i.to]) {
				auto cp = now;
				cp.have += i.cost;
				cp.pos = i.to;
				st.push(cp);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:72:34: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   72 |                         ans = max({ ans,0LL,now.have });
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   template argument deduction/substitution failed:
a.cc:72:34: note:   deduced conflicting types for parameter '_Tp' ('long int' and 'long long int')
   72 |                         ans = max({ ans,0LL,now.have });
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 1 provided