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

Why WA here? Submit onto zju i got AC?

Posted by linghuyong at 2006-09-26 19:57:09 on Problem 2128
//zju2433 Highways
//2006-9-26 16:37

#include "iostream"
using namespace std;

int main()
{
	int cas;
	bool start = true; 
	scanf( "%d", &cas );
	while( cas -- )
	{
		int n;
		scanf( "%d", &n );
		int min = 1000000000;
		int num;
		int  pre;
		int index;
		if( start == false )
			printf( "\n" );
		start = false;
		if( n == 2 || n == 3 )
		{
			for( int i = 0 ; i < n - 1 ; i ++ )
				scanf( "%ld", &num );
			printf( "0\n" );
		}
		else
		{
			pre = 0;
			for( int i = 0 ; i < n - 1 ; i ++ )
			{
				scanf( "%ld", &num );
				if( num - pre < min && i != n -2 && i != 0 )
				{
					min = num - pre;
					index = i;
				}
				pre = num;
			}
			printf( "%ld\n", min + num );
			printf( "%d 1 %d %d\n", n, index + 2, index + 1  );
			//printf( "%d 1 %d %d\n", index + 2, n, index + 1  );
		}
	}
	return 0;
}

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