Language: C++

#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

struct Edge {
	int a,b,c;
};

const int N = 2500+1;
const int M = 5e3+1;
ll dist[N], rev[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	int n,m,p;
	cin>>n>>m>>p;

	vector<Edge> edges;
	For(i,m) {
		int a,b,c;
		cin>>a>>b>>c;
		edges.push_back({a,b,p-c});
	}

	memset(dist,INF,sizeof dist);
	memset(rev,INF,sizeof rev);
	dist[1] = 0;
	rev[n] = 0;
	For(i,n-1) {
		for (const Edge& e : edges) {
			dist[e.b] = min(dist[e.b], dist[e.a]+e.c);
			rev[e.a] = min(rev[e.a], rev[e.b]);
		}
	}
	int ans = 0;
	for (const Edge& e : edges) {
		if (dist[e.a]<INFLL/2 && rev[e.b]<INFLL/2) {
			if (dist[e.a]+e.c < dist[e.b]) {
				cout << -1 << nl;
				return 0;
			}
			ans = min(ans, min(dist[e.a], dist[e.b]));
		}
	}
	cout << -ans << nl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:73:34: error: no matching function for call to 'min(int&, const long long int&)'
   73 |                         ans = min(ans, min(dist[e.a], dist[e.b]));
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:73:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   73 |                         ans = min(ans, min(dist[e.a], dist[e.b]));
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:73:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   73 |                         ans = min(ans, min(dist[e.a], dist[e.b]));
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~