[Cpp]
Description: Brute Force + greedy. You can only select the first and second lakes in turn ...... The last Lake becomes the problem of selecting the optimal solution. You can select the optimal solution and the largest one. Note that the data may be zero, this is to use all the time in the first Lake.
# Include <cstdio>
# Include <cstring>
Int main ()
{
// Freopen ("a.txt", "r", stdin );
Int t [30], f [30], d [30], s [30];
Int h, n, count, p = 0;
While (scanf ("% d", & n )! = EOF)
{
If (! N) break;
If (p) printf ("\ n ");
Scanf ("% d", & h );
H * = 60;
For (int I = 0; I <n; I ++) scanf ("% d", & f [I]);
For (int I = 0; I <n; I ++) scanf ("% d", & d [I]);
Count = t [0] = 0;
For (int I = 1; I <n; I ++)
{
Scanf ("% d", & t [I]);
T [I] = t [I] * 5 + t [I-1];
}
Memset (s, 0, sizeof (s ));
For (int I = 0; I <n; I ++)
{
Int leave = h-t [I];
If (leave <5) break;
Int sum = 0, pos = 0, temp [30], m [30], flag, c;
For (int j = 0; j <= I; j ++)
{
M [j] = f [j];
Temp [j] = 0;
}
While (leave> = 5)
{
Flag = c = 0;
For (int j = 0; j <= I; j ++)
If (m [j]> c)
{
C = m [j];
Pos = j;
Flag = 1;
}
If (! Flag) break;
Temp [pos] + = 5;
Sum + = c;
M [pos]-= d [pos];
Leave-= 5;
}
If (leave> = 5) temp [0] + = leave;
If (sum> count)
{
Count = sum;
For (int j = 0; j <= I; j ++) s [j] = temp [j];
}
}
If (! Count) s [0] = h;
Printf ("% d", s [0]);
For (int I = 1; I <n; I ++) printf (", % d", s [I]);
Printf ("\ nNumber of fish expected: % d \ n", count );
P ++;
}
Return 0;
}