Minimize sum of absolute differences of same-indexed elements of two given arrays by at most one replacement

#include using namespace std;  int minAbsoluteSumDiff(vector A,                       vector B, int N){        int sum = 0;              int diff[N];      for (int i = 0; i < N; i++) {                  diff[i] = abs(A[i] - B[i]);                  sum += diff[i];    }          sort(A.begin(), A.end());              int bestDiff[N];      for (int i = 0; i < N; i++) {                          int j = lower_bound(A.begin(), A.end(), B[i])                - A.begin();                          if (j != 0 && j != N)            bestDiff[i] = min(abs(A[j] - B[i]),                              abs(A[j - 1] - B[i]));                  else if (j == 0)            bestDiff[i] = abs(A[j] - B[i]);                  else if (j == N)            bestDiff[i] = abs(A[j - 1] - B[i]);    }          int bestPick = 0;    for (int i = 0; i < N; i++) {        bestPick = max(bestPick,                       diff[i] - bestDiff[i]);    }          return sum - bestPick;}  int main(){        vector A = { 2, 5, 8 };    vector B = { 7, 6, 1 };      int N = 3;      cout