class Solution {
public:
int minDistance(int height, int width, vector<int>& tree, vector<int>& squirrel, vector<vector<int>>& nuts) {
int sum_nums=0;
//先统计出所有坚果的距离
for(vector<int>&nut:nuts){
sum_nums+=abs(nut[0]-tree[0])+abs(nut[1]-tree[1]);
}
sum_nums<<=1;
int res=INT_MAX;
//针对每个坚果作为松鼠要取的第一个坚果,计算各个距离,并保存最小的距离
for(vector<int>&nut:nuts){
res=min(res,sum_nums-(abs(nut[0]-tree[0])+abs(nut[1]-tree[1]))+(abs(nut[0]-squirrel[0])+abs(nut[1]-squirrel[1])));
}
return res;
}
};