Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct edge {ll to;ll cost;};
vector<edge> g[2505];

vector<int> rev_g[2505];
priority_queue<int> pq;

typedef pair<ll, ll> P;

ll dist[2505];
ll inf=pow(1,50);

bool ok[2505];

void bfs(int v){
  ok[v]=1;
  for(int i=0;i<rev_g[v].size();i++){
    int u = rev_g[v][i];
    if(!ok[u]){
      bfs(u);
    }
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  for(int i=0;i<2505;i++)dist[2505]=inf;

  ll n,m,p;
  cin>>n>>m>>p;
  for(int i=0;i<m;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    g[a].push_back({b, max(0, c-p)});
    rev_g[b].push_back(a);
  }

  bfs(n-1);

  priority_queue<P> pq;
  pq.push({0, 0});
  int cnt=0;
  while(!pq.empty()) {
    cnt++;
    auto p = pq.top();pq.pop();
    auto d = p.first;
    auto v = p.second;
    for(int i=0;i<g[v].size();i++){
      edge e = g[v][i];
      if(!ok[e.to])continue;
      if((dist[e.to] == inf) || (dist[e.to] < dist[v] + e.cost)){
        dist[e.to] = dist[v] + e.cost;
        pq.push({dist[e.to], e.to});
      }
    }
    if(cnt++ > 5000000){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<dist[n-1]<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:41:27: error: no matching function for call to 'max(int, ll)'
   41 |     g[a].push_back({b, max(0, c-p)});
      |                        ~~~^~~~~~~~
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:41:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   41 |     g[a].push_back({b, max(0, c-p)});
      |                        ~~~^~~~~~~~
/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:41:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   41 |     g[a].push_back({b, max(0, c-p)});
      |                        ~~~^~~~~~~~
a.cc:41:19: error: no matching function for call to 'std::vector<edge>::push_back(<brace-enclosed initializer list>)'
   41 |     g[a].push_back({b, max(0, c-p)});
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = edge; _Alloc = std::allocator<edge>; value_type = edge]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<edge>::value_type&' {aka 'const edge&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = edge; _Alloc = std::allocator<edge>; value_type = edge]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<edge>::value_type&&' {aka 'edge&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~