Language: C++

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x[ohara],y,sum[ohara],pos,k,l,dis[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>l>>n;
    rep(i,n)cin>>x[i];
    dis[0]=x[0];
    rrep(i,1,n){
        dis[i]=x[i]-x[i-1];
    }
    dis[n]=l-x[n-1];
    ll sum1[ohara];
    rep(i,n+1)sum1[i]=dis[i],sum[i]=dis[i];
    rrrep(i,n,1){
        sum1[i-1]+=sum[i];
    }
    rrep(i,1,n+1)sum[i]+=sum[i-1];
    rep(i,n){
        ll anss=0,kai;
        kai=min(i-1,n-i-1);
        cnt=0;
        rrrep(j,i-1,0){
            if(cnt==kai)break;
            anss+=sum[j]*2;
            cnt++;
            if(cnt==kai)break;
        }
        cnt=0;
        rrep(j,i+1,n+1){
            if(cnt==kai)break;
            anss+=sum1[j]*2;
            cnt++;
            if(cnt==kai)break;
        }
        anss+=max(sum1[i],sum[i]);
        ans=max(ans,anss);
    }
    Cout(ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:16: error: no matching function for call to 'min(int, ll)'
   46 |         kai=min(i-1,n-i-1);
      |             ~~~^~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:46:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   46 |         kai=min(i-1,n-i-1);
      |             ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:46:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   46 |         kai=min(i-1,n-i-1);
      |             ~~~^~~~~~~~~~~