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

贴个代码供大家参考

Posted by Ly86 at 2010-03-09 12:29:47 on Problem 2181
#include <stdio.h>
int main()
{
	long n;
	scanf("%ld",&n);
	long a,b,c,k;
	long i;
	scanf("%ld",&a);
	for(i=1;i<n;i++)
	{
		if(i==1){
	b = a;
	c = 0;}
	scanf("%ld",&a);
	
		k = c + a > b ? c + a: b;
		c = b - a > c ? b - a: c;
		b = k;
		
	}
	if(b > c) printf("%ld\n",b);
		else
			printf("%ld\n",c);
	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