Language: C++

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct s
{
    int x, y, r;
};
s f;
s p[(int)1005];
long double dist(s x, s y)
{
//    cout << x.x << " " << x.y << " " << x.r << endl ;
//    cout << y.x << " " << y.y << " " << y.r << endl ;
    long double X = x.x-y.x;
    X*=X;
//    cout << X << " " ;
    long double Y = x.y-y.y;
    Y*=Y;
    X+=Y;
    X = sqrt(X);
    X -= x.r;
    X -= y.r;
////    cout << X << " " << x.x << " " << x.y << " ~ " << y.x << " " << y.y << endl;
//    cout << Y << endl;
    return max(0.0,X);
}
int n ;
bool ss(s x, s y)
{
    if(dist(x,f) != dist(y,f))
        return (dist(x,f)-dist(y,f) >= 1e-16);
    else
        return (dist(y,p[0])-dist(x,p[0]) >= 1e-16);
}
long double dp[1005][1005];
long double solve(int idx, int bef)
{
    if(idx == n+1)
    {
        return dist(p[bef],f);
    }
    if(dp[idx][bef] != -1) return dp[idx][bef];
    long double ret = dist(p[bef],f)+dist(p[idx],p[bef]);
    ret = min(ret,dist(p[idx],p[bef])+solve(idx+1,idx));
    ret = min(ret,solve(idx+1,bef));
    return dp[idx][bef] = ret;
}
int main()
{
    for(int i = 0 ; i < 1005 ; i++)
        for(int j = 0 ; j < 1005; j++) dp[i][j] = -1;
    cin >>p[0].x >> p[0].y ;
    p[0].r = 0;
    cin >> f.x >> f.y;
    f.r = 0 ;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        cin >>p[i].x >> p[i].y >> p[i].r;
    sort(p+1,p+n+1,ss);
    cout << fixed << setprecision(10) << solve(0,0) << "\n";
}


Compiler output:
a.cc: In function 'long double dist(s, s)':
a.cc:25:15: error: no matching function for call to 'max(double, long double&)'
   25 |     return max(0.0,X);
      |            ~~~^~~~~~~
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:25:15: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long double')
   25 |     return max(0.0,X);
      |            ~~~^~~~~~~
/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:25:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   25 |     return max(0.0,X);
      |            ~~~^~~~~~~