Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

werte

Posted by 904013041 at 2005-01-03 19:29:39 on Problem 2128
#include <stdio.h>
#include <iostream.h>
void main(){
	long int x[50000]={0},n,i,k,j,d[50000]={0},tem=0,t=0;
	cin>>n;
	for(i=0;i<n-1;i++)
		cin>>x[i];
	if(n==2){
		cout<<x[0]<<endl;
		cout<<"2"<<"1"<<endl;
	}
	for(j=1;j<n-2;j++)
		d[j-1]=x[j]-x[j-1];
	for(j=0;j<n-4;j++){
		for(k=0;k<n-4-j;k++){
			if(d[k]>d[k+1]){
				tem=d[k];
				d[k]=d[k+1];
				d[k+1]=tem;
				t=k;
			}
		}
	}
	cout<<d[0]+x[n-2]<<endl;
	cout<<t+3<<" "<<"1"<<" "<<n<<" "<<t+2<<endl;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator