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

纪念我的第一次,一次AC&0MS(慎入,有代码)

Posted by cc163ok2 at 2012-07-18 15:55:07 on Problem 1323
#include<stdio.h>
main()
{
	int m,n,i,p,e,r,max,jl,js=1;
	int w[51];
	while(scanf("%d %d",&m,&n)!=EOF)
	{  
		if(m==0) break;
		for(i=1;i<=n;i++)
		{
			scanf("%d",&w[i]);
		}
		for(p=m*n,e=0,r=0;p>0;p--)
		{
			for(i=1,max=0;i<=n;i++)
			{
				if(max<w[i]) {max=w[i];jl=i;}
			}
			if(max==p)w[jl]=0;
			if(max==p&&r==0) {e++;}
			else if(max==p&&r!=0){r--;}
			else{r++;}
		}
		printf("Case %d: %d\n",js,e);
		js++;
	}
}

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