Language: C++

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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 9000000000000000000;

using namespace std;
using ll = unsigned long long int;
using P = pair<int, int>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, n, m) for (ll i = (n); i < (m); i++)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()))
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()))

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

template <typename T, typename U> U READ(ll V, T a, U b) {
  REP(i, V) {
    cin >> a;
    b.push_back(a);
  }
  return b;
}

int main() {
  ll N = 0;
  vector<ll> A;
  vector<ll> B;
  ll sum = 0;
  ll po = 0;
  cin >> N;
  REP(i, N) {
    cin >> po;
    A.push_back(po);
    sum += po;
    B.push_back(sum);
  }
  ll mi = llINF;
  FOR(i, 1, N - 1) {
    ll left = B[i];
    ll right = B[N - 1] - B[i];
    ll lh = left / 2, rh = right / 2;
    ll l1 = lower_bound(B.begin(), B.begin() + i, lh) - B.begin();
    ll l2 = lower_bound(B.begin() + i, B.end(), left + rh) - B.begin();
    ll w[2] = {0, -1};
    REP(k, 4) {
      vector<ll> pa(4);
      pa[0] = B[l1 + w[k % 2]];
      pa[1] = B[i] - B[l1 + w[k % 2]];
      pa[2] = B[l2 + w[k / 2]] - B[i];
      pa[3] = B[N - 1] - B[l2 + w[k / 2]];
      if (MIN(pa) == 0) {
        continue;
      }
      mi = min(mi, abs(MAX(pa) - MIN(pa)));
    }
  }
  cout << mi << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:19: error: narrowing conversion of '-1' from 'int' to 'll' {aka 'long long unsigned int'} [-Wnarrowing]
   65 |     ll w[2] = {0, -1};
      |                   ^~
a.cc:75:23: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
   75 |       mi = min(mi, abs(MAX(pa) - MIN(pa)));
      |                    ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/bits/stl_algo.h:71,
                 from /usr/include/c++/14/algorithm:61,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~