| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
那位大哥可以指点一下,我的程序我什么会time limit exceed啊#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator