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 |
why too slow?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator