func_code_string: #include <bits/stdc++.h>   using namespace std;   void Get(int &T) {     char C;     bool F = 0;     for (; C = getchar(), C <  0  || C >  9 ;)       if (C ==  - ) F = 1;     for (T = C -  0 ; C = getchar(), C >=  0  && C <=  9 ; T = T * 10 + C -  0 )       ;     F && (T = -T);   }   int N, M;   int X[10005];   int Y[10005];   int G[1005][1005];   int A[10005];   void Debug() {     for (int i = 1; i <= N; i++) {       for (int j = 1; j <= N; j++) printf( %d  , G[i][j]);       puts(  );     }   }   void Init() {     Get(N);     Get(M);     for (int i = 2; i < N; i++) Get(A[i]);     for (int k = 1; k <= N; k++) {       Get(X[k]);       X[k] *= M;       Get(Y[k]);       Y[k] *= M;     }     for (int i = 1; i <= N; i++)       for (int j = 1; j <= N; j++)         if (i != j)           G[i][j] = std::abs(X[i] - X[j]) + std::abs(Y[i] - Y[j]) - A[i];   }   int Ans;   void Work() {     for (int k = 1; k <= N; k++)       for (int i = 1; i <= N; i++)         for (int j = 1; j <= N; j++)           if (G[i][j] > G[i][k] + G[k][j]) G[i][j] = G[i][k] + G[k][j];     Ans = G[1][N];   }   void Output() { printf( %d n , Ans); }   int main() {     Init();     Work();     Output();     return 0;   }   