`
isiqi
  • 浏览: 16550713 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

PKUOJ1042 Gone Fishing

阅读更多
Gone Fishing
Time Limit:2000MS Memory Limit:32768K
Total Submissions:19098 Accepted:5374

Description

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.

Input

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.

Output

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.

Sample Input

2 
1 
10 1 
2 5 
2 
4 
4 
10 15 20 17 
0 3 4 3 
1 2 3 
4 
4 
10 15 50 30 
0 3 4 3 
1 2 3 
0 

Sample Output

45, 5 
Number of fish expected: 31 

240, 0, 0, 0 
Number of fish expected: 480 

115, 10, 50, 35 
Number of fish expected: 724 
【题解】都是从最后一个湖结束,所以总路程相同,可以忽略不计。剩下的只要每次取可以捕的最多的鱼的湖,用优先队列来实现贪心!
分享到:
评论

相关推荐

    acm贪心 gone fishing

    贪心 贪心John is going on a fishing trip. He has h hours available (1 ), and there are n lakes in the area (2 ) all reachable along a single, one-way road. John starts at lake 1, but he can finish at ...

    PKU 1042 代码

    PKU 1042 Gone fishing 代码 已通过。。。

    gone fishing

    Problem D:Gone Fishing Time Limit:1000MS Memory Limit:65536K Total Submit:999 Accepted:366 Language: not limited Description John is going on a fishing trip. He has h hours available (1 ), and ...

    Gone Fishing

    John is going on a fishing trip. He has h hours available (1 ), and there are n lakes in the area (2 ) all reachable along a single, one-way road. John starts at lake 1, but he can finish at any lake ...

    经典ACM题Gone Fishing C++源代码

    《经典ACM题“Gone Fishing”的C++源代码解析》 ACM竞赛中的题目“Gone Fishing”是一道涉及枚举与贪心算法的经典问题。该题目要求参赛者设计算法,帮助John在一系列湖泊中钓鱼,使得他能获得最大的总鱼数。问题的...

    G9 -- Gone Fishing

    标题 "G9 -- Gone Fishing" 是一个典型的 ACM (国际大学生程序设计竞赛) 题目,这类题目通常涉及算法设计和高效代码实现。这道题目可能是关于解决某个具体问题或挑战,比如模拟、搜索、图论、动态规划等。ACM编程...

    ACM经典C++题目:Gone Fishing算法详解及源代码.doc

    ACM经典C++题目:Gone Fishing算法详解及源代码.doc

    Android 的Gone 实例

    在Android开发中,`Gone`是一个非常关键的布局管理属性,它用于控制视图(View)在屏幕上的可见性。本教程将深入探讨`Gone`属性的使用,以及如何在实际应用中灵活地调整界面元素的可见状态。通过学习这个实例,你将...

    解决On no!Something has gone wrong.

    Something has gone wrong." 是一个常见的错误提示,通常表示系统遇到了问题或有软件运行异常。解决这个问题需要一系列步骤,包括诊断错误来源、修复相关组件和确保系统的稳定运行。以下是一些相关的Linux知识和...

    Gone Mad Player

    《Gone Mad Player:强大的音乐播放器解析》 在当今数字化时代,音乐播放器作为音频内容的主要载体,其功能和性能对于音乐爱好者来说至关重要。"Gone Mad Player"就是这样一款备受推崇的音乐播放器,以其强大的功能...

    TV_B_GONE.zip_Gone!_TV_builtcgn_remote

    TV_B_GONE.zip_Gone!_TV_builtcgn_remote 是一个压缩文件,根据其名称推测,它可能与一种名为 "TV B-Gone" 的设备或技术有关。TV B-Gone 是一种小型遥控器,设计用于关闭大多数电视,无论品牌或型号。这个设备通常...

    acm PKU最详细的分类

    6. **1042 Gone Fishing/DP** - 再次出现动态规划,这意味着题目可能涉及某种资源分配或路径选择的优化问题。动态规划能够帮助找到全局最优解,尤其是在处理具有重叠子问题和最优子结构特性的问题时。 7. **1054 ...

    [英文版.飘.ebook].Gone.With.the.Wind.pdf

    从给定的文件信息来看,我们讨论的是一本经典的文学作品——《飘》(Gone with the Wind),作者是玛格丽特·米切尔(Margaret Mitchell)。这本小说不仅在美国文学史上占据着重要的地位,而且在全球范围内也享有极...

    IOS类似android的view.gone/view.visable

    在Android系统中,我们可以使用`View.GONE`和`View.VISIBLE`来控制视图的可见性,这两种状态有着明确的含义:`GONE`表示视图不仅不可见,而且不占用布局空间;而`VISIBLE`则表示视图是可见的。那么在iOS中,如何实现...

    英语学习\阅读用\飘(gone with the wind)英汉对照.rar

    《飘》(Gone with the Wind)是一部世界文学名著,由玛格丽特·米切尔创作,首次发表于1936年。这部作品以其深刻的人物刻画、宏大的历史背景和动人的爱情故事,成为了美国南部历史和文化的象征。在英语学习中,《飘...

    gone with the wind

    - **《飘》(Gone with the Wind)**: 是一本由玛格丽特·米切尔创作的经典美国小说,首次出版于1936年。该书不仅在文学界取得了巨大成功,还被改编成了同名电影,并在世界各地广受欢迎。 - **故事背景**: 故事发生...

    gone with wind 全英文版的好东东

    ### Gone with the Wind – 关键知识点解析 #### 标题:Gone with the Wind(《飘》) - **作品名称**:“Gone with the Wind”是美国文学中的经典之作,通常被译作《飘》。这部小说以美国南北战争为背景,讲述了...

    算法艺术与信息学竞赛题目完全解析

    - **题目示例**:Pku1042——Gone Fishing,利用贪心策略解决实际问题,即在每个步骤选择当前状态下最佳的选择,期望最终能得到全局最优解。 - **题目示例**:Pku1700——Crossing River,同样是通过局部最优选择...

    Clicky Gone(一键隐藏窗口) v1.4.4.1

    Clicky Gone是一款高效实用的系统工具,主要用于帮助用户快速隐藏并恢复桌面窗口。这款软件的主要功能是通过设置快捷键,让用户在操作过程中更加便捷地管理屏幕上的应用程序窗口。它的核心特性在于其一键隐藏和恢复...

Global site tag (gtag.js) - Google Analytics