采用贪心策略。

假设他从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. Android 自定义PopupWindow动画效果

    public class RollActivity extends Activity { private View view; private Button btn; private PopupWin ...

  2. 14.3.5 LOCK TABLES and UNLOCK TABLES Syntax

    14.3.5 LOCK TABLES and UNLOCK TABLES Syntax LOCK TABLES tbl_name [[AS] alias] lock_type [, tbl_name ...

  3. C#代码 json类

    using System; using System.Collections.Generic; using System.Collections; using System.Text; using S ...

  4. 一次使用Eclipse Memory Analyzer分析Tomcat内存溢出(转)

    前言 在平时开发.测试过程中.甚至是生产环境中,有时会遇到OutOfMemoryError,Java堆溢出了,这表明程序有严重的问题.我们需要找造成OutOfMemoryError原因.一般有两种情况 ...

  5. 自己改写了一个图片局部放大的jquery插件页面里面的html代码少了,同一个页面可以调用多个

    自己改写了一个图片局部放大的jquery插件页面里面的html代码少了,同一个页面可以调用多个,兼容ie8以上浏览器,别忘了引用jquery,我用的jquery/1.11.0/其他版本没有测试,另外需 ...

  6. C# 中的关键字之:base、this 【转】

                                                                                 C# 中的关键字之:base.this. ba ...

  7. Java虚拟机类载入顺序

    Java虚拟机在载入类的时候.先初始化父类静态变量.再初始化子类静态变量.然后载入父类,最后载入子类 public class Parent { static{ System.out.println( ...

  8. 小心ThreadLocal的陷阱

    ThreadLocal用在多线程时保存线程级的局部变量,当我们需要在线程内共享数据时,ThreadLocal屡试不爽,但是ThreadLocal也会有一个问题,当你使用线程池时,线程可能会被重用,所以 ...

  9. EF项目中应用出现问题???

    最近用EF做了个项目发现很多不便利的地方. 具体如下. 1,我是通过edmx 建模,然后通过模型生成数据库. 虽然数据库已经创建成功但是问题来了,我在加字段,和标的时候再次生成时domeo.edmx. ...

  10. ASP.NET中怎样才能使自己的代码运行的效率更高

    一.网页设计相关: 1,做好页面布局和内容规划,只放置合适的内容,并尽可能使页面设计的最小. 2,使用好的网页编辑器,如DW,FP,不要用VS自带的编辑器,因为它会产生很多无用的沉余代码,而且设计的界 ...