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 |
Re:没感觉有什么啊,怎么会超时呢??,好心人看一下In Reply To:没感觉有什么啊,怎么会超时呢??,好心人看一下 Posted by:dexter at 2004-04-29 23:25:02 > #include<stdio.h> > #include<string.h> > #include<stdlib.h> > char tag[sizeof("ENDOFINPUT")]; > struct bus > { > int m; > int routs[10]; > int close; > }buses[20]; > int art;//arrive time > int N; > void count() > { > int sum,i,j; > int min; > min=100000;//so big > for(i=0;i<N;i++) > { > sum=0; > j=0; > while(1) > { > if(sum>=art) > { > buses[i].close=sum; > if(sum<min) > min=sum; > break; > } > if(j==buses[i].m) > j=0; > sum+=buses[i].routs[j]; > j++; > } > } > printf("%d\n",min-art); > } > int main() > { > int n,i,len,j; > char str[50]; > while(1) > { > scanf("%s",tag); > if(!strcmp(tag,"ENDOFINPUT")) > break; > scanf("%d",&N); > getchar(); > for(i=0;i<N;i++) > { > n=0; > gets(str); > len=strlen(str); > for(j=0;str[j];j++) > if(str[j]==' ') > str[j]=0; > for(j=0;j<len;) > { > buses[i].routs[n]=atoi(&str[j]); > n++; > j=j+strlen(&str[j])+1; > } > buses[i].m=n; > } > scanf("%d",&art); > count(); > scanf("%s",tag); > } > } > Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator