<pre name="code" class="cpp">#include<iostream>
#include<math.h>
using namespace std;
int main(int argc, char *argv[]){
int cityNum;
cin>>cityNum;
int e1, s2;
int shortDistance=pow(10.0,9);
int preDistance;
int firstCityDistance;//
int twoCityDistance;//
for(int i=2;i<=cityNum-1;i++){
cin>>firstCityDistance;
if(i>2){
twoCityDistance=firstCityDistance-preDistance;
if(twoCityDistance<shortDistance){
e1=i;
s2=e1-1;
shortDistance=twoCityDistance;
//cout<<shortDistance<<endl;
}
}
preDistance=firstCityDistance;
}
cin>>firstCityDistance;
if(cityNum<=3){
cout<<0<<endl;
}else{
cout<<shortDistance+firstCityDistance<<endl;
cout<<e1<<" "<<1<<" "<<cityNum<<" "<<s2<<endl;
}
return 0;
}
POJ-2128
最新推荐文章于 2019-03-30 19:50:04 发布