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 |
请教哪位牛人,TL,就是TL!!!哪位大侠帮帮忙看看啊!#include<stdio.h> #include<stdlib.h> void KNAP(int k,int h,int *f,int *d,int *t,int *Ti,int *Ma); int main() { int n,h,fi[26],di[26],ti[26],time[26],Max[26],max,m; int i,j; while(1) { scanf("%d",&n); if(n==0) break; scanf("%d",&h); h=h*60; for(i=1;i<=n;i++) scanf("%d",&fi[i]); for(j=1;j<=n;j++) scanf("%d",&di[j]); for(i=1;i<n;i++) { scanf("%d",&ti[i]); ti[i]=5*ti[i];} for(j=1;j<=n;j++) KNAP(j,h,fi,di,ti,time,Max); max=1; for(i=2;i<=n;i++) {if(Max[max]<Max[i]) max=i;} m=Max[max]; for(i=0;i<26;i++) {time[i]=0; Max[i]=0;} KNAP(max,h,fi,di,ti,time,Max); for(i=1;i<n;i++) printf("%d,",time[i]); printf("%d\n",time[n]); printf("Number of fish expected:%d\n\n",m); } return 0; } void KNAP(int k,int h,int *f,int *d,int *t,int *Ti,int *Ma) { int i,max,maxfish,fish[26]; for(i=1;i<k;i++) {h-=t[i];} for(i=1;i<=k;i++) { fish[i]=f[i]; } for(i=0;i<26;i++) Ti[i]=0; maxfish=0; while(h!=0) { max=1; for(i=2;i<=k;i++) {if(fish[max]<fish[i]) max=i;} maxfish=maxfish+fish[max]; Ti[max]+=5; h-=5; if(fish[max]>d[max]) fish[max]-=d[max]; else fish[max]=0; } Ma[k]=maxfish; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator