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:没有啊,你只要统计出占用的次数最多的一段就可以了

Posted by zhujie at 2006-03-15 09:05:32 on Problem 1083
In Reply To:没有啊,你只要统计出占用的次数最多的一段就可以了 Posted by:Sempr at 2006-03-14 23:19:48
请问这样做对吗?我就是统计出占用次数最多的一段,可就是WA啊,查不出哪错了
#include <stdio.h>

int main()
{
	int cas,n,i,up,down,temp;
	int a[200];
	scanf("%d",&cas);
	while (cas--)
	{
		scanf("%d",&n);
		for (i=0; i<200; i++)  a[i] = 0;
		while (n--)
		{
			scanf("%d %d",&down,&up);
			if (down > up)  
			{
				temp = down;
				down = up;
				up = down;
			}
			down = (down - 1) / 2;
			up = (up - 1) / 2;
			
			for (i=down; i<=up; i++)
				a[i]++;
		}
		int max = 0;
		for (i=0; i<200; i++)
			if (a[i] > max)  max = a[i];
		printf("%d\n",max * 10);
	}
	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