2022.1.29
题目网址:
http://bailian.openjudge.cn/practice/1042/
原题:
Gone Fishing
总时间限制:
2000ms
内存限制:
65536kB
描述
John is going on a fishing trip. He has h hours available (1 <= h <= 16), and there are n lakes in the area (2 <= n <= 25) all reachable along a single, one-way road. John starts at lake 1, but he can finish at any lake he wants. He can only travel from one lake to the next one, but he does not have to stop at any lake unless he wishes to. For each i = 1,...,n - 1, the number of 5-minute intervals it takes to travel from lake i to lake i + 1 is denoted ti (0 < ti <=192). For example, t3 = 4 means that it takes 20 minutes to travel from lake 3 to lake 4. To help plan his fishing trip, John has gathered some information about the lakes. For each lake i, the number of fish expected to be caught in the initial 5 minutes, denoted fi( fi >= 0 ), is known. Each 5 minutes of fishing decreases the number of fish expected to be caught in the next 5-minute interval by a constant rate of di (di >= 0). If the number of fish expected to be caught in an interval is less than or equal to di , there will be no more fish left in the lake in the next interval. To simplify the planning, John assumes that no one else will be fishing at the lakes to affect the number of fish he expects to catch.
Write a program to help John plan his fishing trip to maximize the number of fish expected to be caught. The number of minutes spent at each lake must be a multiple of 5.
输入
You will be given a number of cases in the input. Each case starts with a line containing n. This is followed by a line containing h. Next, there is a line of n integers specifying fi (1 <= i <=n), then a line of n integers di (1 <=i <=n), and finally, a line of n - 1 integers ti (1 <=i <=n - 1). Input is terminated by a case in which n = 0.
输出
For each test case, print the number of minutes spent at each lake, separated by commas, for the plan achieving the maximum number of fish expected to be caught (you should print the entire plan on one line even if it exceeds 80 characters). This is followed by a line containing the number of fish expected.
If multiple plans exist, choose the one that spends as long as possible at lake 1, even if no fish are expected to be caught in some intervals. If there is still a tie, choose the one that spends as long as possible at lake 2, and so on. Insert a blank line between cases.
翻译:
描述:
约翰正在钓鱼旅行。他一共有 h 个小时可以用(1<=h<=16),该区域沿着一条单行道
n (2<=n<=25)个湖泊。约翰从湖泊1开始,但是他能到达任何一个他想去的湖泊。他
能从一个湖泊到下一个湖泊,但是他不用必须停在任何一个湖泊除非他想停下。对于每个i =
1,...,n-1,从湖i到湖i+1的5分钟间隔数是t[i]。例如,t[3]=4意味着约翰花了20分钟从
3到湖4。为了帮约翰计划好他的钓鱼旅行,约翰收集了一些关于这些湖泊的的信息。对
每个湖泊 i ,在最初的5分钟能抓到的鱼的数量是f[i](f[i]>=0)。每个钓鱼的五分钟比
一个钓鱼的五分钟所钓的鱼少d[i](d[i]>0)。如果预期抓到的鱼的数量小于或等于d[i],
么下一次不能抓到鱼了。为了简化这个计划,约翰认为没有其他人在湖泊影响他预期抓到
的数量。
写一个程序去帮助约翰计划他的钓鱼旅行,使约翰钓到的鱼的数量最大。在每个湖中花的时间必须是5的倍数。
输入:
输入中你将被给定许多的例子。每个例子第一行为n。接下来一行是h。再接下来,有n行整数,是n个f[i],接下来一行是n个d[i],最后一行为n-1个整数t[i]。输入以一个0结束。
输出:
对于每一个测试样例,打印出每个湖所花的时间,以逗号分隔开来,使所抓的鱼最多(你应该将整个计划打印在一行上,即使它超过了80个字符)。接下来一行打印抓到的鱼的最大数量。
如果有多个计划可行,那么选择在湖泊1中花时间最长的,即使在这期间没有抓到鱼。如果在湖泊1中所花时间一样的话,那么选择在湖泊2中花时间最长的,以此类推。每个例子之间输出一个空行。