Language: C++

#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 2505, INF = 1e9;
const ll M = 5005;

#define int ll


int n, m, p;

struct EDGE {
    int to, nex, cost;
} edge[M];
int head[N], cntedge;
void Addedge(int u, int v, int w) {
    edge[++cntedge] = (EDGE) { v, head[u], w };
    head[u] = cntedge;
}

int Q[N * M], l, r;
int dis[N], cnt[N], inq[N];
int SPFA() {
    memset(dis, -1, sizeof dis);
    Q[++r] = 1, inq[1] = true, dis[1] = 0;
    while (l < r) {
        int u = Q[++l]; inq[u] = false;
        if ((++cnt[u]) > n) return -1;
        for (int i = head[u], v; i; i = edge[i].nex) {
            v = edge[i].to;
            if (dis[v] < dis[u] + edge[i].cost) {
                dis[v] = dis[u] + edge[i].cost;
                if (!inq[v]) Q[++r] = v, inq[v] = true;
            }
        }
    }
    return max(0, dis[n]);
}

signed main() {
    n = read<int>(), m = read<int>(), p = read<int>();
    rep (i, 1, m) {
        int x = read<int>(), y = read<int>(), c = read<int>();
        Addedge(x, y, c - p);
    }
    cout << SPFA() << endl;
    return 0;
}



Compiler output:
a.cc: In function 'long long int SPFA()':
a.cc:54:15: error: no matching function for call to 'max(int, long long int&)'
   54 |     return max(0, dis[n]);
      |            ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:4:
/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:54:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   54 |     return max(0, dis[n]);
      |            ~~~^~~~~~~~~~~
/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
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:5:
/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:54:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   54 |     return max(0, dis[n]);
      |            ~~~^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:59:10: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   59 |     rep (i, 1, m) {
      |          ^
a.cc:10:35: note: in definition of macro 'rep'
   10 | #define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
      |                                   ^
a.cc:59:10: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   59 |     rep (i, 1, m) {
      |          ^
a.cc:10:44: note: in definition of macro 'rep'
   10 | #define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
      |                                            ^