采用贪心策略。

假设他从1湖泊走到x 湖泊,这还剩下 h*12 - sigma(T1--Tx-1)。(单位时间为5分钟)。然后再用剩下的时间去钓1-x的湖泊的鱼。 每次都选择最多鱼的湖泊钓。

code:

#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
const int maxn = 30; int f[maxn], tf[maxn], d[maxn], t[maxn], path[maxn];
int ans, p[maxn]; int main()
{
int h, n, i, j, k;
while(scanf("%d",&n),n) {
scanf("%d",&h);
h *= 12;
for(i=1; i<=n; ++i) scanf("%d",&f[i]);
for(i=1; i<=n; ++i) scanf("%d",&d[i]);
for(i=1; i<=n-1; i++) scanf("%d",&t[i+1]);
for(i=2,t[1]=0; i<=n; ++i) t[i] += t[i-1];
ans = -1000;
for(k=1; k<=n; ++k)
if(h>t[k]) {
int th = h - t[k];
int sum = 0;
memset(path, 0, sizeof path );
for(i=1; i<=n; ++i) tf[i] = f[i];
while(th>0) {
int maxx = 0;
int mark = 0;
for(i=1; i<=k; ++i)
if(maxx<tf[i]) {
maxx = tf[i];
mark = i;
}
if(!mark) break;
sum += maxx;
tf[mark] -= d[mark];
path[mark]++;
th--;
}
path[1] += th;
if(ans<sum) {
ans = sum;
for(j=1; j<=n; j++)
p[j] = path[j];
}
}
for(i=1; i<n; ++i) printf("%d, ",p[i]*5);
printf("%d\n",p[i]*5);
printf("Number of fish expected: %d\n\n", ans);
}
return 0;
}

POJ1042 Gone Fishing的更多相关文章

  1. ZOJ 1015 Fishing Net(弦图判定)

    In a highly modernized fishing village, inhabitants there make a living on fishery. Their major tool ...

  2. bzoj 1242: Zju1015 Fishing Net 弦图判定

    1242: Zju1015 Fishing Net弦图判定 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 214  Solved: 81[Submit ...

  3. Poj/OpenJudge 1042 Gone Fishing

    1.链接地址: http://bailian.openjudge.cn/practice/1042/ http://poj.org/problem?id=1042 2.题目: Gone Fishing ...

  4. POJ 1042 Gone Fishing (贪心)(刘汝佳黑书)

    Gone Fishing Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 30281   Accepted: 9124 Des ...

  5. uva757 - Gone Fishing(馋)

    题目:uva757 - Gone Fishing(贪心) 题目大意:有N个湖泊仅仅有一条通路将这些湖泊相连. 每一个湖泊都会给最開始5分钟间隔内能够调到的鱼(f).然后给每过5分钟降低的鱼的数量(d) ...

  6. ●BZOJ 1006 [HNOI2008]神奇的国度(弦图最小染色数)○ZOJ 1015 Fishing Net

    ●赘述题目 给出一张弦图,求其最小染色数. ●题解 网上的唯一“文献”:<弦图与区间图>(cdq),可以学习学习.(有的看不懂) 摘录几个解决改题所需的知识点: ●子图和诱导子图(一定要弄 ...

  7. Cocos2d-X开发教程-捕鱼达人 Cocos2-x development tutorial - fishing talent

    Cocos2d-X开发教程-捕鱼达人 Cocos2-x development tutorial - fishing talent 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱 ...

  8. CSU 1859 Gone Fishing(贪心)

    Gone Fishing [题目链接]Gone Fishing [题目类型]贪心 &题解: 这题要先想到枚举走过的湖,之后才可以贪心,我就没想到这,就不知道怎么贪心 = = 之后在枚举每个湖的 ...

  9. Gone Fishing(贪心)

    Gone Fishing John is going on a fising trip. He has h hours available (1 ≤ h ≤ 16), and there are n ...

随机推荐

  1. Inno Setup 安装inf文件的一个例子

    原文 http://zwkufo.blog.163.com/blog/static/2588251201063033524889/ ; INF安装例子; [Setup]; 注意: AppId 的值是唯 ...

  2. Oracle 索引扫描的4种类型

    根据索引的类型与where限制条件的不同,有4种类型的Oracle索引扫描: 3,4可归一种 (1) 索引唯一扫描(index uniquescan) (2) 索引范围扫描(index range s ...

  3. Vis.js图表插件

    Vis.js是一款基于JavaScript的可视化图表库,Vis.js不像其他的图表库那样仅仅支持几种常用的数据图表,比如线形图.柱状图.饼图等,Vis.js支持上百种不同类型的可视化图表类型,比如时 ...

  4. word2vec 入门(二)使用教程篇

    word2vec 要解决问题: 在神经网络中学习将word映射成连续(高维)向量,这样通过训练,就可以把对文本内容的处理简化为K维向量空间中向量运算,而向量空间上的相似度可以用来表示文本语义上的相似度 ...

  5. MapReduce工作机制

    MapReduce是什么? MapReduce是一种分布式计算模型,由Google提出,主要用于搜索领域,MapReduce程序本质上是并行运行的,因此可以解决海量数据的计算问题. MapReduce ...

  6. ReactNative常见报错

    1.导出模块错误 遇到这样的错误,首先检查代码有闭合一致,如果没有错误的话,则去检查是否是导出模块的错误. 如: export default moduleName; 改为: module.expor ...

  7. OC基础14:使用文件

    "OC基础"这个分类的文章是我在自学Stephen G.Kochan的<Objective-C程序设计第6版>过程中的笔记. 1.对于NSFileManager类,文件 ...

  8. android listiew适配器

    List<Map<String>> Items = new ArrayList<Map<String>>(); // 把该显示的内容放到list中 fo ...

  9. J2EE学习的一部分--JDBC详细说明

    今天是关于我们JDBC相关知识,左右JDBC我想大家都很熟悉的,我记得在很早以前就开始使用它,我记得那是一个大二的学生做课程设计.但随后以完成任务,所以遇到的问题google,当时没有时间组织,下关于 ...

  10. Your build settings specify a provisioning profile with the UUID, no such provisioning profile was found的解决方案

    在Archive项目时,出现了“Your build settings specify a provisioning profile with the UUID “”, however, no suc ...