Language: C++

#include <iostream>
#define NMAX 100000
using namespace std;

int min[NMAX], max[NMAX];
long long c[NMAX], dp[NMAX];
int n;
long long e, t;

long long mxm(long long a, long long b);

int main()
{
	cin >> n >> e >> t;
	int prec = -1e9, m = 0, cit;

	while (n--) {
		cin >> cit;
		if (cit - prec > t) {
			m++;
			min[m] = cit;
		}
		max[m] = cit;
		prec = cit;
	}

	for (int i = 1; i <= m; i++)
		c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];

	for (int i = 1; i <= m; i++)
		dp[i] = dp[i - 1] + c[i] + 1ll * (min[i] - max[i - 1]);

	cout << (long long) dp[m] + e - max[m];

	return 0;
}

long long mxm(long long a, long long b)
{
	if (a > b)
		return a;
	return b;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:25: error: reference to 'min' is ambiguous
   21 |                         min[m] = cit;
      |                         ^~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 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/c++/14/bits/stl_algobase.h:281:5: note: candidates are: '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:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:5: note:                 'int min [100000]'
    5 | int min[NMAX], max[NMAX];
      |     ^~~
a.cc:23:17: error: reference to 'max' is ambiguous
   23 |                 max[m] = cit;
      |                 ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:16: note:                 'int max [100000]'
    5 | int min[NMAX], max[NMAX];
      |                ^~~
a.cc:28:35: error: reference to 'max' is ambiguous
   28 |                 c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];
      |                                   ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:16: note:                 'int max [100000]'
    5 | int min[NMAX], max[NMAX];
      |                ^~~
a.cc:28:44: error: reference to 'min' is ambiguous
   28 |                 c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];
      |                                            ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: '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:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:5: note:                 'int min [100000]'
    5 | int min[NMAX], max[NMAX];
      |     ^~~
a.cc:28:58: error: reference to 'max' is ambiguous
   28 |                 c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];
      |                                                          ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:16: note:                 'int max [100000]'
    5 | int min[NMAX], max[NMAX];
      |                ^~~
a.cc:28:67: error: reference to 'min' is ambiguous
   28 |                 c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];
      |                                                                   ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: '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:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:5: note:                 'int min [100000]'
    5 | int min[NMAX], max[NMAX];
      |     ^~~
a.cc:31:51: error: reference to 'min' is ambiguous
   31 |                 dp[i] = dp[i - 1] + c[i] + 1ll * (min[i] - max[i - 1]);
      |                                                   ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: '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:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:5: note:                 'int min [100000]'
    5 | int min[NMAX], max[NMAX];
      |     ^~~
a.cc:31:60: error: reference to 'max' is ambiguous
   31 |                 dp[i] = dp[i - 1] + c[i] + 1ll * (min[i] - max[i - 1]);
      |                                                            ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:16: note:                 'int max [100000]'
    5 | int min[NMAX], max[NMAX];
      |                ^~~
a.cc:33:41: error: reference to 'max' is ambiguous
   33 |         cout << (long long) dp[m] + e - max[m];
      |                                         ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:5:16: note:                 'int max [100000]'
    5 | int min[NMAX], max[NMAX];
      |                ^~~