Language: C++

#include<cstdio>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<queue>



using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;
pair<int,int> map[100002];
long long int time[100002];



int main(){
		int N,L;
		scanf("%d %d",&N,&L);
		rep(i,N){
			int a;
			scanf("%d",&a);
			map[i]=make_pair(a,i);
		}
		sort(map,map+N,greater< pair<int,int> >() );
		long long int ans=0;
		rep(i,N){
			long long int sans=0;
			int yokomax=0;
			if(map[i].second!=0){yokomax=max(time[map[i].second+1],yokomax);}
			if(map[i].second!=N-1){yokomax=max(time[map[i].second-1],yokomax);}
			sans=yokomax+L-map[i].first;
			time[map[i].second]=sans;
			ans=max(ans,sans);
		}
		printf("%lld\n",ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:57: error: no matching function for call to 'max(long long int&, int&)'
   31 |                         if(map[i].second!=0){yokomax=max(time[map[i].second+1],yokomax);}
      |                                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from /usr/include/c++/14/math.h:36,
                 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:31:57: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |                         if(map[i].second!=0){yokomax=max(time[map[i].second+1],yokomax);}
      |                                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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,
                 from a.cc:3:
/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:31:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |                         if(map[i].second!=0){yokomax=max(time[map[i].second+1],yokomax);}
      |                                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:32:59: error: no matching function for call to 'max(long long int&, int&)'
   32 |                         if(map[i].second!=N-1){yokomax=max(time[map[i].second-1],yokomax);}
      |                                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:32:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   32 |                         if(map[i].second!=N-1){yokomax=max(time[map[i].second-1],yokomax);}
      |                                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:32:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |                         if(map[i].second!=N-1){yokomax=max(time[map[i].second-1],yokomax);}
      |                                                        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~