Language: C++

#include<bits/stdc++.h>
using namespace  std;
typedef long long ll;
const int maxx=1e5+2;
struct S{
    int to;ll val;
};
vector<S> a[maxx];
ll d[maxx];
int n,m,cnt[maxx];
bool vis[maxx];
int ok[maxx];
bool spfa(){
    memset(d,0x3f,sizeof d);
    for(int i=1;i<=n;i++){
        vis[i]=0;
        cnt[i]=0;
    }
    d[1]=0;vis[1]=1;
    queue<int> q;
    while(!q.empty()) q.pop();
    q.push(1);
    while((!q.empty())){
        int t=q.front();q.pop();
        vis[t]=0;
        if(cnt[t]>=n) return 1;
        for(int i=0;i<a[t].size();i++){
            S k=a[t][i];
            if(!ok[k.to]) continue;
            if(d[k.to]>d[t]+k.val){
                d[k.to]=d[t]+k.val;
                cnt[k.to]++;
                if(cnt[k.to]>=n) return 1;
                if(!vis[k.to]){
                    vis[k.to]=1;
                    q.push(k.to);

                }
            }
        }
    }
    return 0;
}
vector<int> b[maxx];
queue<int> q;
int book[maxx];
int main(){
    int p;
    cin>>n>>m>>p;
    //for(int i=1;i<=n;i++) a[i].clear();
    for(int i=1;i<=m;i++){
        int x,y,z;
        cin>>x>>y>>z;
        b[y].push_back(x);
        z-=p;
        a[x].push_back(S{y,1ll*-z});
    }
    q.push(n); book[n]=1; ok[n]=1;
    while(!q.empty()){
        int x=q.front(); q.pop();
        for(auto t:b[x]){
            if(book[t])  continue;
            q.push(t);
            book[t]=1;
            ok[t]=1;
        }
    }
    if(!ok[1]) return 0*puts("0");
    if(spfa()) return 0*puts("-1");
    ll ans=-d[n];
    cout<<max(0,ans)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:14: error: no matching function for call to 'max(int, ll&)'
   71 |     cout<<max(0,ans)<<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:71:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   71 |     cout<<max(0,ans)<<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:71:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   71 |     cout<<max(0,ans)<<endl;
      |           ~~~^~~~~~~