Language: C++

/// Bellman Ford
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

time_t bg;

double tt()
{
        time_t nd=clock();
        return (double)(nd-bg)/CLOCKS_PER_SEC;
}

const ll N=2500+7;
ll n,m,p;
vector <pair <ll,ll>> g[N];

struct situation
{
        ll nod;
        ll ans;
};

bool operator < (situation a,situation b)
{
        return a.ans>b.ans;
}

ll ans[N];
bool pot[N];
vector <ll> inv[N];

void rundfs(ll nod)
{
        pot[nod]=1;
        for(auto &nou : inv[nod])
                if(pot[nou]==0)
                        rundfs(nou);
}

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

       /// freopen("input","r",stdin);

        bg=clock();

        cin>>n>>m>>p;
        for(ll i=1;i<=n;i++)
        {
                ll a,b,c;
                cin>>a>>b>>c;
                c-=p;
                c*=-1;
                g[a].push_back({b,c});
                inv[b].push_back(a);
        }

        for(ll i=2;i<=n;i++)
                ans[i]=(ll)1e1e8;

        rundfs(n);

        priority_queue <situation> pq;
        pq.push({1,0});
        while(!pq.empty() && tt()<=1.9)
        {
                ll nod=pq.top().nod,cur=pq.top().ans;
                pq.pop();
                if(ans[nod]!=cur)
                        continue;
                for(auto &it : g[nod])
                {
                        ll nou=it.first;
                        if(!pot[nou]) continue;
                        ll cost=it.second;
                        ll coc=cur+cost;
                        if(coc<ans[nou])
                        {
                                ans[nou]=coc;
                                pq.push({nou,coc});
                        }
                }
        }
        /// ciclu negativ ?!?!?!?
        for(ll i=1;i<=n;i++)
        {
                if(!pot[i]) continue;
                for(auto &it : g[i])
                {
                        ll j=it.first;
                        if(!pot[j]) continue;
                        if(ans[i]+it.second<ans[j])
                        {
                                cout<<"-1\n";
                                return 0;
                        }
                }
        }
        cout<<max(0,-ans[n])<<"\n";

        return 0;
}
/**

**/


Compiler output:
a.cc: In function 'int main()':
a.cc:64:28: error: unable to find numeric literal operator 'operator""e8'
   64 |                 ans[i]=(ll)1e1e8;
      |                            ^~~~~
a.cc:104:18: error: no matching function for call to 'max(int, ll)'
  104 |         cout<<max(0,-ans[n])<<"\n";
      |               ~~~^~~~~~~~~~~
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:2:
/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:104:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  104 |         cout<<max(0,-ans[n])<<"\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:
/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:104:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  104 |         cout<<max(0,-ans[n])<<"\n";
      |               ~~~^~~~~~~~~~~