Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };

int n, l;
vector<int> turara;
vector<int> time;

int dfs(int now)
{
	if(time[now] != -1) return time[now];

	int ret = 0;
	if(turara[now - 1] > turara[now])
	{
		ret = dfs(now - 1);
	}
	if(turara[now + 1] > turara[now])
	{
		ret = max(ret, dfs(now + 1));
	}
	ret += l - turara[now];

	return time[now] = ret;
}

int main(void)
{
	ios::sync_with_stdio(false);
	while(cin >> n >> l && n)
	{
		turara.resize(n + 2);
		time = Array(n + 2, -1);
		time[0] = time[n + 1] = 0;
		turara[0] = turara[n + 1] = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> turara[i + 1];
		}

		int ans = 0;
		for (int i = 1; i <= n; i++)
		{
			ans = max(ans, dfs(i));
		}

		cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc:42:13: error: 'std::vector<int> time' redeclared as different kind of entity
   42 | vector<int> time;
      |             ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int dfs(int)':
a.cc:46:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   46 |         if(time[now] != -1) return time[now];
      |                    ^
a.cc:46:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   46 |         if(time[now] != -1) return time[now];
      |            ~~~~~~~~~~^~~~~
a.cc:46:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   46 |         if(time[now] != -1) return time[now];
      |                                            ^
a.cc:46:44: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
   46 |         if(time[now] != -1) return time[now];
      |                                            ^
      |                                            |
      |                                            time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:59:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   59 |         return time[now] = ret;
      |                        ^
a.cc:59:26: error: assignment of read-only location '*(time + ((sizetype)now))'
   59 |         return time[now] = ret;
      |                ~~~~~~~~~~^~~~~
a.cc: In function 'int main()':
a.cc:68:22: error: assignment of function 'time_t time(time_t*)'
   68 |                 time = Array(n + 2, -1);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~
a.cc:69:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   69 |                 time[0] = time[n + 1] = 0;
      |                       ^
a.cc:69:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   69 |                 time[0] = time[n + 1] = 0;
      |                                     ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:69:39: error: assignment of read-only location '*(time + (((sizetype)n) + 1))'
   69 |                 time[0] = time[n + 1] = 0;
      |                           ~~~~~~~~~~~~^~~