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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#include<cstdio> #include<cstring> #include<iostream>
#define MAXN 30
using namespace std;
int f[MAXN],d[MAXN],t[MAXN],n,ans[MAXN],tot[MAXN][200],h;
void init() { h *= 12; for(int i = 1;i <= n;i ++) scanf("%d",&f[i]); for(int i = 1;i <= n;i ++) scanf("%d",&d[i]); for(int i = 1;i < n;i ++) scanf("%d",&t[i]); for(int i = 1;i <= n;i ++) for(int j = 1;j <= h;j ++) tot[i][j] = max(f[i] - d[i] * (j - 1) , 0); }
void calc() { int far = 1,tmp[MAXN] = {0},index[MAXN] = {0},sum = -0xfffffff; while(far <= n) { tmp[far] = tmp[far-1] + t[far]; if(tmp[far] >= h) break; far++; } if(far > n) far = n; int cnt = 1; while(cnt <= far) { int tsum = 0; memset(index , 0 , sizeof(index)); int th = h - tmp[cnt-1]; for(int i = 1;i <= th;i ++) { int tmax = 0,tj = 1; for(int j = 1;j <= cnt;j ++) { if(tot[j][index[j]+1] > tmax) { tj = j; tmax = tot[j][index[j]+1]; } } tsum += tmax; index[tj] ++; } if(tsum > sum) { sum = tsum; memcpy(ans , index , sizeof(index)); } cnt ++; } for(int i = 1;i <= n;i ++) { if(i == n) printf("%d\n",ans[i] * 5); else printf("%d, ",ans[i] * 5); } printf("Number of fish expected: %d\n\n",sum); }
int main() { freopen("./1042.in" , "r" , stdin); while(cin>>n>>h) { init(); calc(); } return 0; }
|