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:郁闷了一上午,删除所有优化后AC了In Reply To:郁闷了一上午,删除所有优化后AC了 Posted by:xnby at 2005-12-03 11:51:21 呵呵,改了一下,加了一个标志,保证只有在至少一个设备带宽满足假设带宽的时候才进行max的计算,恩,ac了^_^ #include<stdio.h> main() { int b[100][100],m[100],p[100][100]; int i,j,k,l,bmax,bmin,sump,t,n,tmin; double max; scanf("%d",&t); for(i=0;i<t;i++) { bmax=0;bmin=32767; scanf("%d",&n); for(j=0;j<n;j++) { scanf("%d",&m[j]); for(k=0;k<m[j];k++) { scanf("%d%d",&b[j][k],&p[j][k]); if (bmax<b[j][k]) bmax=b[j][k]; if (bmin>b[j][k]) bmin=b[j][k]; } } max=0.0; bool selected; for(j=bmin;j<=bmax;j++) { selected = false; sump=0; for(k=0;k<n;k++) { tmin=32767; for(l=0;l<m[k];l++) { if(b[k][l]>=j&&p[k][l]<tmin) { tmin=p[k][l]; if (b[k][l]==j) selected = true; } } sump+=tmin; } if (selected == true) if((double)j/(double)sump>max)max=(double)j/(double)sump; } printf("%.3lf\n",max); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator