Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{ int from, to, cost; } ;

static const ll INF  = 1e10;
static const int MAX_E = 5e3;
static const int MAX_V = 2500;

edge es[MAX_E];     //辺

ll d[MAX_V];
int V, E, P;

void shortest_path(int s){
    for(int i = 0; i < V; i++) d[i] = INF;
    d[s] = 0;
    int cnt = 0;
    while (true){
        cnt++;
        bool update = false;
        for(int i = 0; i < E; i++){
            edge e = es[i];
            if( d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update) break;
        if(cnt > E + 10){
            for(int i = 0; i < V + 10; i++){
                for(int j = 0; j < E; j++){
                    edge e = es[j];
                    if ( d[e.from] != INF && d[e.to] > d[e.from] + e.cost ){
                        d[e.to] = -INF;
                        update = true;
                    }
                }
            }
            break;
        }
    }
    if(d[V-1] == -INF ) cout << -1 << endl;
    else cout << max(0,-d[V-1]) << endl;
}

bool find_negative_loop(){
    memset(d, INF, sizeof(d));
    d[0] = 0;

    for(int i = 0; i < V; i++){
        for(int j = 0; j < E; j++){
            edge e = es[j];
            //cout << "e.from: " << e.from << " e.to :" << e.to << " e.cost " << e.cost << endl; 
            if( d[e.to] > d[e.from] + e.cost){
                //cout << "d[e.to]: " << d[e.to] << " d[e.from]" << d[e.from] << endl;
                d[e.to] = d[e.from] + e.cost;

                //cout << "i "<< i << " j " << j <<  " e.from: " << e.from << " e.to :" << e.to << " e.cost " << e.cost << endl; 
                
                //V回目にもゴールの点の更新があるなら負の閉路が存在する
                if( i == V - 1 && e.to == V - 1) return true;
            }
        }
    }
    return false;
}

int main(){
    cin >> V >> E >> P;
    for(int i = 0; i < E; i++){
        int a, b, c; cin >> a >> b >> c; a--, b--;
        es[i] = {a, b, -(c - P)};
    }
    /*if(find_negative_loop()) {
        cout << -1 << endl;
        return 0;
    }*/
    shortest_path(0);
}

Compiler output:
a.cc: In function 'void shortest_path(int)':
a.cc:44:21: error: no matching function for call to 'max(int, ll)'
   44 |     else cout << max(0,-d[V-1]) << endl;
      |                  ~~~^~~~~~~~~~~
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:   template argument deduction/substitution failed:
a.cc:44:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   44 |     else cout << max(0,-d[V-1]) << endl;
      |                  ~~~^~~~~~~~~~~
/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:
/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:44:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   44 |     else cout << max(0,-d[V-1]) << endl;
      |                  ~~~^~~~~~~~~~~
a.cc: In function 'bool find_negative_loop()':
a.cc:48:15: warning: overflow in conversion from 'll' {aka 'long long int'} to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   48 |     memset(d, INF, sizeof(d));
      |               ^~~