1 #include <iostream>
2 #include <cstdio>
3 #include <cstdlib>
4 #include <cstring>
5 #define max(a, b) ((a) > (b) ? (a) : (b))
6 #define min(a, b) ((a) < (b) ? (a) : (b))
7
8 inline void read(int &x)
9 {
10 x = 0;char ch = getchar(), c = ch;
11 while(ch < ‘0‘ || ch > ‘9‘)c = ch, ch = getchar();
12 while(ch <= ‘9‘ && ch >= ‘0‘)x = x * 10 + ch - ‘0‘, ch = getchar();
13 if(c == ‘-‘)x = -x;
14 }
15
16 const int MAXN = 100 + 5;
17
18 int a,b,c,p1,p2,p3,n,dp[MAXN][MAXN][MAXN],t[MAXN];
19 //dp[i][j][k]表示前i条流水线,生产j个汉堡,k个薯条,能生产多少饮料
20
21 int ma,sum,ans;
22 //最多生产多少套
23
24 int main()
25 {
26 read(a), read(b), read(c);
27 read(p1), read(p2), read(p3);
28 read(n);
29 for(register int i = 1;i <= n;++ i) read(t[i]), sum += t[i];
30 ma = sum / (a * p1 + b * p2 + c * p3);
31 int tmp1 = min(100, ma * a), tmp2 = min(100, ma * b), tmp3 = min(100, ma * c);
32 for(register int i = 1;i <= n;++ i)
33 for(register int j = tmp1;j >= 1;-- j)
34 for(register int k = tmp2;k >= 1;-- k)
35 {
36 for(register int jj = j;jj >= 1;-- jj)
37 {
38 for(register int kk = k;kk >= 1;-- kk)
39 {
40 dp[i][j][k] = max(dp[i][j][k], dp[i - 1][jj][kk] + (t[i] - (j - jj)*p1 - (k - kk)*p2)/p3);
41 if(dp[i][j][k] > 100)break;
42 }
43 if(dp[i][j][k] > 100)break;
44 }
45 ans = max(ans, min(j/a, min(k/b, dp[i][j][k]/c)));
46 if(dp[i][j][k] > 100)break;
47 }
48 printf("%d", ans);
49 return 0;
50 }