1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std;
int main() { int max,time[26],i,j,f[26],fb[26],d[26],t[26],n,h; while(scanf("%d",&n;)&&n;) { memset(time,0,sizeof(time)); max=-1; scanf("%d",&h;); h*=60; for(i=1;i<=n;i++) scanf("%d",&fb;[i]); for(i=1;i<=n;i++) scanf("%d",&d;[i]); t[1]=0; for(i=2;i<=n;i++) { int temp; scanf("%d",&temp;); t[i]=t[i-1]+temp; } for(i=1;i<=n;i++) { memcpy(f,fb,(i+1)*sizeof(f[0])); int sum=0; int th=h-t[i]*5; int temp[26]; memset(temp,0,sizeof(temp)); while(th>0) { int maxn=0,maxi=1; for(j=1;j<=i;j++) if(f[j]>maxn) { maxn=f[j]; maxi=j; } temp[maxi]+=5; sum+=maxn; f[maxi]-=d[maxi]; th-=5; } if(sum>max) { max=sum; memcpy(time,temp,(i+1)*sizeof(f[0])); } } for(i=1;i<n;i++) printf("%d, ",time[i]); printf("%dn",time[n]); printf("Number of fish expected: %dnn",max); } }
|