博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Poj/OpenJudge 1042 Gone Fishing
阅读量:6208 次
发布时间:2019-06-21

本文共 3840 字,大约阅读时间需要 12 分钟。

1.链接地址:

http://bailian.openjudge.cn/practice/1042/

http://poj.org/problem?id=1042

2.题目:

Gone Fishing
Time Limit: 2000MS   Memory Limit: 32768K
Total Submissions: 27652   Accepted: 8199

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

Source

3.思路:

DP

4.代码:

1 //2010-04-22 2 //v0.1 create by wuzhihui 3 #include
4 using namespace std; 5 6 int ti[194];//ti (0 < ti <=192 7 int fi[194]; 8 int fi2[194]; 9 int di[194];10 int a[194];11 int maxa[194];12 int main()13 {14 int i,j;15 int h,h2;//hour between 1<=h<=1616 int n;//lake 2 <= n <= 2517 int fishes;18 int maxfishes,temp;19 int max;20 while((cin>>n)&&n!=0)21 {22 cin>>h;23 for(i=0;i
>fi[i];24 for(i=0;i
>di[i];25 for(i=0;i
>ti[i];26 max=-1;27 for(j=0;j
0)37 {38 maxfishes=-1;39 for(j=0;j<=i;j++)40 {41 if(fi2[j]>maxfishes)42 {43 maxfishes=fi2[j];44 temp=j;45 }//if46 }//for_j47 fishes+=maxfishes;48 a[temp]++;49 if(fi2[temp]

 

 

转载于:https://www.cnblogs.com/mobileliker/p/3546631.html

你可能感兴趣的文章
Windows更新补丁下载、批量安装的几种方法
查看>>
Petapoco使用SQLite的异常问题
查看>>
tomcat 指定的服务未安装(总结验证)
查看>>
redhat6.4 安装oracle 10g error
查看>>
我的友情链接
查看>>
关闭子窗口 父窗口自动刷新
查看>>
linux下安装thinkpad小红点和滚轮的驱动
查看>>
opencv 在debian6.0下安装
查看>>
简单了解tengine
查看>>
我的友情链接
查看>>
EditPlus自定义模板
查看>>
The Best Way to Unit Test in Android
查看>>
ln链接使用
查看>>
存档:老系统 WINDOWS 95 98 XP NT系统号
查看>>
CentOS系统启动流程你懂否
查看>>
深入浅出分布式文件系统MogileFS集群
查看>>
WebLogic常见问题
查看>>
html - <meta name="viewport" content="XX"/> 标签常见属性及说明
查看>>
发布一个http请求封装类
查看>>
常用归档压缩命令
查看>>