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

那位大哥可以指点一下,我的程序我什么会time limit exceed啊

Posted by yuxxt at 2006-09-11 12:47:41 on Problem 2153
#include<iostream>
#include<string>

using namespace std;

struct student
{
	string name;
	int total;
};

void main()
{
	student std[10000];
	int n,m;
	int lc;
	char *name=new char[100];
	string t;
	int score;
	int i=0,j;
	int counter;
	cin>>n;
	getchar();
	for(i=0;i<n;i++)
	{
		std[i].total=0;
		cin.getline(name,100);
		std[i].name=name;
	}
	cin>>m;
	while(m>=1)
	{
		for(i=0;i<n;i++)
		{
			cin>>score;
			getchar();
			cin.getline(name,100);
			t=name;
			for(j=0;j<n;j++)
			{
			if(std[j].name==t)
			{
				std[j].total+=score;
				break;
			}
			}
		}
	
		for(i=0;i<n;i++)
		if(std[i].name=="Li Ming")
			lc=std[i].total;
		counter=1;
		for(i=0;i<n;i++)
		{
			if(std[i].total>lc)
				counter++;
		}
		cout<<counter<<endl;
		m--;
	}
}



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