Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;

ll N, Z, W;
vector<ll> A;

void input() {
    cin >> N >> Z >> W;
    A.resize(N);
    for (auto& a : A)
        cin >> a;
}

void solve() {
    if (N == 1) {
        cerr << abs(A.back() - W) << endl;
    } else {
        ll min_to_back = *min_element(A.begin(), A.end() - 1, [](auto a) {
            return abs(a - A.back());
        });
        cout << max(abs(A.back() - W), abs(min_to_back - A[N - 1])) << endl;
    }
}


int main() {
    input();
    solve();
    
    return 0;
}



Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 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/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Iterator2 = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Compare = solve()::<lambda(auto:1)>]':
/usr/include/c++/14/bits/stl_algo.h:5562:12:   required from 'constexpr _ForwardIterator std::__min_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<solve()::<lambda(auto:1)> >]'
 5562 |         if (__comp(__first, __result))
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5613:43:   required from 'constexpr _FIter std::min_element(_FIter, _FIter, _Compare) [with _FIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _Compare = solve()::<lambda(auto:1)>]'
 5613 |       return _GLIBCXX_STD_A::__min_element(__first, __last,
      |                                           ^
a.cc:31:38:   required from here
   31 |         ll min_to_back = *min_element(A.begin(), A.end() - 1, [](auto a) {
      |                           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   32 |             return abs(a - A.back());
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~ 
   33 |         });
      |         ~~                            
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(solve()::<lambda(auto:1)>) (long long int&, long long int&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
a.cc:31:63: note: candidate: 'template<class auto:1> solve()::<lambda(auto:1)>'
   31 |         ll min_to_back = *min_element(A.begin(), A.end() - 1, [](auto a) {
      |                                                               ^
a.cc:31:63: note:   candidate expects 1 argument, 2 provided