Language: C++

#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define int long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 7;
const double P = 3.141592653589793238462643;

int n, z, w, a[N], mx = -inf, pos, ans = -inf;

main()
{
    cin >> n >> z >> w;
    mx = z;
    for( int i = 1; i <= n; i++ )
    {
        cin >> a[i];
        if( a[i] >= mx )
        {
            mx = a[i];
            pos = i;
        }
    }
    ans = abs(mx - w);
    for( int i = mx; i <= n; i++ )
    {
        for( int j = i; j <= n; j++ )
            ans = max( abs(a[i] - a[j]), ans );
    }
    cout << ans;
}



















#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define int long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 7;
const double P = 3.141592653589793238462643;

int n, z, w, a[N], mx = -inf, pos, ans = -inf;

main()
{
    cin >> n >> z >> w;
    mx = z;
    for( int i = 1; i <= n; i++ )
    {
        cin >> a[i];
        if( a[i] >= mx )
        {
            mx = a[i];
            pos = i;
        }
    }
    ans = abs(mx - w);
    for( int i = mx; i <= n; i++ )
    {
        for( int j = i; j <= n; j++ )
            ans = max( abs(a[i] - a[j]), ans );
    }
    cout << ans;
}









































Compiler output:
a.cc:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   20 | main()
      | ^~~~
a.cc:73:11: error: redefinition of 'const long long int N'
   73 | const int N = 1e5 + 10;
      |           ^
a.cc:14:11: note: 'const long long int N' previously defined here
   14 | const int N = 1e5 + 10;
      |           ^
a.cc:74:11: error: redefinition of 'const long long int inf'
   74 | const int inf = 1e9 + 7;
      |           ^~~
a.cc:15:11: note: 'const long long int inf' previously defined here
   15 | const int inf = 1e9 + 7;
      |           ^~~
a.cc:75:14: error: redefinition of 'const double P'
   75 | const double P = 3.141592653589793238462643;
      |              ^
a.cc:16:14: note: 'const double P' previously defined here
   16 | const double P = 3.141592653589793238462643;
      |              ^
a.cc:77:5: error: redefinition of 'long long int n'
   77 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |     ^
a.cc:18:5: note: 'long long int n' previously declared here
   18 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |     ^
a.cc:77:8: error: redefinition of 'long long int z'
   77 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |        ^
a.cc:18:8: note: 'long long int z' previously declared here
   18 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |        ^
a.cc:77:11: error: redefinition of 'long long int w'
   77 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |           ^
a.cc:18:11: note: 'long long int w' previously declared here
   18 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |           ^
a.cc:77:14: error: redefinition of 'long long int a [100010]'
   77 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |              ^
a.cc:18:14: note: 'long long int a [100010]' previously declared here
   18 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |              ^
a.cc:77:20: error: redefinition of 'long long int mx'
   77 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |                    ^~
a.cc:18:20: note: 'long long int mx' previously defined here
   18 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |                    ^~
a.cc:77:31: error: redefinition of 'long long int pos'
   77 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |                               ^~~
a.cc:18:31: note: 'long long int pos' previously declared here
   18 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |                               ^~~
a.cc:77:36: error: redefinition of 'long long int ans'
   77 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |                                    ^~~
a.cc:18:36: note: 'long long int ans' previously defined here
   18 | int n, z, w, a[N], mx = -inf, pos, ans = -inf;
      |                                    ^~~
a.cc:79:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   79 | main()
      | ^~~~
a.cc:79:1: error: redefinition of 'int main()'
a.cc:20:1: note: 'int main()' previously defined here
   20 | main()
      | ^~~~