Language: C++

#include <bits/stdc++.h>
using namespace std;

void chmin(int64_t &x, int64_t y) {
    if (x > y) x = y;
}

int64_t dp[2020][2020];

int main() {
    int n;
    int64_t T, E;
    cin >> n >> E >> T;
    vector<long long> x(n);
    for (int i = 0; i < n; i++) scanf("%lld", &x[i]);
    vector<int64_t> d(n), ds(n + 1);
    for (int i = 0; i < n - 1; i++) d[i] = x[i + 1] - x[i];
    for (int i = 0; i < n; i++) ds[i + 1] = ds[i] + d[i];

    if (n > 2000) return 0;

    fill_n(*dp, 2020 * 2020, 1e17);
    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            // wait
            if (j == 0) {
                chmin(dp[i + 1][0], dp[i][j] + T + d[i]);
            }

            // return
            if (j > 0) {
                int64_t dist = ds[i] - ds[i - j];
                chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
            }

            // ignore
            if (i < n - 1) {
                chmin(dp[i + 1][j + 1], dp[i][j] + d[i]);
            }
        }
    }

    int64_t ans = dp[n][0] + x[0] + (E - x[n - 1]);
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:58: error: no matching function for call to 'max(long long int, int64_t)'
   35 |                 chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
      |                                                       ~~~^~~~~~~~~~~~~~~~~~~
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:35:58: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   35 |                 chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
      |                                                       ~~~^~~~~~~~~~~~~~~~~~~
/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:35:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   35 |                 chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
      |                                                       ~~~^~~~~~~~~~~~~~~~~~~