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

Re:哪里还没考虑到啊,牛人看看啊,附代码wa

Posted by BJ05_1096 at 2007-05-10 23:42:12 on Problem 2181
In Reply To:哪里还没考虑到啊,牛人看看啊,附代码wa Posted by:inforyou at 2007-05-10 23:34:59
> #include <stdio.h>
> #include <stdlib.h>
> 
> int main()
> {
> 	int i = 0,j,n,max,min,num=0,nb[150000];
> 	scanf("%d",&n);
> 	for(j = 0; j < n; j++)
> 	{
> 		scanf("%d",&nb[j]);
> 	}
> 	while(i < n-1)
> 	{
> 		max = nb[i];
> 		while(max < nb[++i])
> 		{
> 			max = nb[i];
> 			if(i == n-1) break;
> 		}
> 		num += max;
> 		if(i == n-1)
> 		{
> 			printf("%d\n",num);
> 			return 0;
> 		}
> 		min = nb[i];
> 		while(min > nb[++i])
> 		{
> 			min = nb[i];
> 			if(i == n-1)
> 			{
> 				min = 0;break;
> 			}
> 
> 		}
> 		num -= min;
> 		if(i == n-1)
> 		{
> 			printf("%d\n",num);
> 			return 0;
> 		}
> 	}
> 	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