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

气人,数据都过了,可是交了之后是WA,帮忙看一下,贴代码。

Posted by RUNSLOWLY at 2008-09-04 14:49:09 on Problem 2287 and last updated at 2008-09-04 14:49:31
#include<stdio.h>
void sort(int *p,int n)
{
	int i,j,k;
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
			if(*(p+i)<*(p+j))
			{
				k=*(p+i);
				*(p+i)=*(p+j);
				*(p+j)=k;
			}
	}
}
int compertition(int n,int *p1,int *p2)
{
	int i,j,num=0;
	num=0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(*(p2+j)==0)
				continue;
			if(*(p1+i)>*(p2+j))
			{
				*(p1+i)=0;
				*(p2+j)=0;
				break;
			}
			else
				if(*(p1+i)==*(p2+j))
			{
				*(p1+i)=0;
				*(p2+j)=0;
				num++;
				break;
			}

		}
		
	}
    return num;
}
int main()
{
	int i,n,p1[1001],p2[1001],flag,num,he;
	while(1)
	{
		scanf("%d",&n);
		if(!n)  break;
		for(i=0;i<n;i++)
			scanf("%d",&p1[i]);
		for(i=0;i<n;i++)
			scanf("%d",&p2[i]);
		sort(p1,n);
		sort(p2,n);
		he=compertition(n,p1,p2);
		flag=0;
		num=0;
		for(i=0;i<n;i++)
		{
			if(*(p2+i)!=0)
				flag++;
			if(*(p1+i)!=0)
				num++;
		}
		if(n-num-he>flag)
			printf("%d\n",(n-num-he-flag)*200);
		else
			if(flag+he==n-num)
				printf("0\n");
			else
				printf("%d\n",(n-num-he-flag)*200);
	}
 	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