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

why too slow?

Posted by RE at 2006-09-19 20:59:07 on Problem 2153
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 10001
#define M 51

typedef struct student{
    char str[31];
	int score;
}student;

int main()
{
	int n;
	student p[N];
	int m,t,i,j,k;
	char name[31];
	int  score,lc;
	scanf("%d\n",&n);
	lc=-1;
	for(i=0;i<n;i++)
	{
		gets(p[i].str);
        if(lc<0&&strcmp(p[i].str,"Li Ming")==0) 
		{
			lc=i;
		}
		p[i].score=0;
	}
    scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
		{
		        scanf("%d ",&score);
		    	gets(name);
                for(t=0;t<n;t++)
				{
			        if(strcmp(p[t].str,name)==0)
					{
			        	k=t;
			    	 break;
					}
				}
	    	    p[k].score+=score;
		}
        int cnt=1;
        for(j=0;j<n;j++)
		{
	     	   if(p[j].score>p[lc].score) 
			   {
					cnt++;
			   }
		}
		printf("%d\n",cnt);
	}
	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