Language: C++

#pragma GCC optimize("O3")

#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];

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});
	}
	shuffle(edges.begin(), edges.end());

	memset(dist,INF,sizeof dist);
	dist[1] = 0;
	For(i,n-1) {
		for (const Edge& e : edges) {
			dist[e.b] = min(dist[e.b], dist[e.a]+e.c);
		}
	}
	ll len = dist[n];
	while (clock()<1.96*CLOCKS_PER_SEC) {
		for (const Edge& e : edges) {
			dist[e.b] = min(dist[e.b], dist[e.a]+e.c);
		}
	}
	if (len == dist[n]) {
		cout << max(0, -dist[n]) << nl;
	} else {
		cout << -1 << nl;
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:16: error: no matching function for call to 'shuffle(std::vector<Edge>::iterator, std::vector<Edge>::iterator)'
   57 |         shuffle(edges.begin(), edges.end());
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:3697:5: note: candidate: 'template<class _RAIter, class _UGenerator> void std::shuffle(_RAIter, _RAIter, _UGenerator&&)'
 3697 |     shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:3697:5: note:   candidate expects 3 arguments, 2 provided
a.cc:73:28: error: no matching function for call to 'max(int, ll)'
   73 |                 cout << max(0, -dist[n]) << nl;
      |                         ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60:
/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:   template argument deduction/substitution failed:
a.cc:73:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   73 |                 cout << max(0, -dist[n]) << nl;
      |                         ~~~^~~~~~~~~~~~~
/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, 2 provided
/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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:73:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   73 |                 cout << max(0, -dist[n]) << nl;
      |                         ~~~^~~~~~~~~~~~~