Topcoder-SRM596DIV2-250

#include
#include
#include
using namespace std;
class FoxAndSightseeing{
public:
int getMin(vector position){
int distanceLess[position.size()];
for(int i=1;i distanceLess[i]=abs(position[i]-position[i-1])+abs(position[i]-position[i+1])-abs(position[i+1]-position[i-1]);
}
int missingPoint=1;
int maxDistanceLess=0;
for(int i=1;i if(distanceLess[i]>maxDistanceLess){
missingPoint=i;
maxDistanceLess=distanceLess[i];
}
}
int ret=0;
for(int i=1;i if(i!=missingPoint){
ret+=abs(position[i]-position[i-1]);
}
else{
ret+=abs(position[i+1]-position[i-1]);
i++;
}
cout<<"ret:"< }
return ret;
}
};

你可能感兴趣的:(算法)