Gold miner

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1889    Accepted Submission(s): 740
Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Problem Description
Homelesser likes playing Gold miners in class. He has to pay much attention to the teacher to avoid being noticed. So he always lose the game. After losing many times, he wants your help.

To make it easy, the gold becomes a point (with the area of 0). You are given each gold's position, the time spent to get this gold, and the value of this gold. Maybe some pieces of gold are co-line, you can only get these pieces in order. You can assume it can turn to any direction immediately.
Please help Homelesser get the maximum value.
 
Input
There are multiple cases.
In each case, the first line contains two integers N (the number of pieces of gold), T (the total time). (0<N≤200, 0≤T≤40000)
In each of the next N lines, there four integers x, y (the position of the gold), t (the time to get this gold), v (the value of this gold). (0≤|x|≤200, 0<y≤200,0<t≤200, 0≤v≤200)
 
Output
Print the case number and the maximum value for each test case.
 
Sample Input
3 10
1 1 1 1
2 2 2 2
1 3 15 9
3 10
1 1 13 1
2 2 2 2
1 3 4 7
 
Sample Output
Case 1: 3
Case 2: 7
 
Author
HIT
 
Source
 
Recommend
zhuyuanchen520
 #include <stdio.h>
#include <string.h>
#include <cmath>
#include <algorithm>
using namespace std; struct Node
{
int x;
int y;
int t;
int v;
}a[]; bool cmp(Node pp,Node qq)
{
double px,py,qx,qy;
px=(double)pp.x,py=(double)pp.y;
qx=(double)qq.x,qy=(double)qq.y;
if(fabs(atan2(px,py)-atan2(qx,qy))>(1e-))
{
return atan2(px,py)<atan2(qx,qy);
}
else
{
return (px*px+py*py)<(qx*qx+qy*qy);
}
} bool compare(Node pp,Node qq)
{
double px,py,qx,qy;
px=(double)pp.x,py=(double)pp.y;
qx=(double)qq.x,qy=(double)qq.y;
if(fabs(atan2(px,py)-atan2(qx,qy))<=(1e-))
return true;
else
return false;
} int dp[][],coc[][]; int main()
{
int n,T,cas=;
int i,j,k;
int b[];
while(scanf("%d %d",&n,&T)!=EOF)
{
memset(b,,sizeof(b));
for(i=;i<=n;i++)
scanf("%d %d %d %d",&a[i].x,&a[i].y,&a[i].t,&a[i].v);
sort(a+,a+n+,cmp);
for(i=;i<n;i++)
{
for(j=i+;j<=n;j++)
{
if(compare(a[i],a[j]))
b[i]++;
else
break;
}
}
for(i=;i<=n;i++)
{
for(j=;j<=T;j++)
{
dp[i][j]=;
coc[i][j]=;
}
} for(i=;i<=n;i++)
{
for(j=;j<=T;j++)
{
dp[i][j]=coc[i][j];
} for(j=;j+a[i].t<=T;j++)
{
dp[i][j+a[i].t]=max(dp[i][j+a[i].t],coc[i][j]+a[i].v);
if(b[i]>)
{
coc[i+][j+a[i].t]=max(coc[i+][j+a[i].t],coc[i][j]+a[i].v);
}
} for(j=;j<=T;j++)
{
dp[i][j]=max(dp[i-][j],dp[i][j]);
coc[i+b[i]+][j]=max(coc[i+b[i]+][j],dp[i][j]);
}
} /*for(i=1;i<=n;i++)
printf("%d ",a[i].v);
printf("\n\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=T;j++)
{
printf("%d ",coc[i][j]);
}
printf("\n");
}
printf("\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=T;j++)
{
printf("%d ",dp[i][j]);
}
printf("\n");
}
printf("\n");*/ int ans=;
for(j=;j<=T;j++)
if(dp[n][j]>ans)
ans=dp[n][j];
printf("Case %d: %d\n",cas++,ans);
}
return ;
}

2012 #5 Gold miner的更多相关文章

  1. HDU 4341 Gold miner(分组背包)

    题目链接 Gold miner 目标是要在规定时间内获得的价值总和要尽可能大. 我们先用并查集把斜率相同的物品分在同一个组. 这些组里的物品按照y坐标的大小升序排序. 如果组内的一个物品被选取了,那该 ...

  2. HDU-4341 Gold miner 题解

    题目大意 黄金矿工的游戏,不过每个金块可以看做是质点,没有大小,给出每个金块的坐标.抓取所花费的时间(包括返回的时间),以及价值,其中有一些金块可能会共线.求在规定时间内所获得的最大价值. 样例 样例 ...

  3. 【HDOJ】4341 Gold miner

    分组01背包.在一条直线上的点归为一组. /* 4341 */ #include <iostream> #include <sstream> #include <stri ...

  4. 【HDU - 4341】Gold miner(分组背包)

    BUPT2017 wintertraining(15) #8B 题意 给出每个黄金的坐标.价值及耗时,同一方向的黄金只能依次取,求T时间内收获的最大值. 题解 同一方向,物品前缀和构成的组合,相当于是 ...

  5. HDU 4341 Gold miner (分组背包)

    先把线按照距离原点的距离排序,然后用叉积把在同一条直线上的点放在一起, 把在同一条线上的点中的前i个点当成一个点就转化成了分组背包. 写if(kas++) putchar('\n') 居然PE了,PE ...

  6. [USACO 2012 Open Gold] Bookshelf【优化dp】

    传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=138 传送门2:http://www.lydsy.com/JudgeOn ...

  7. [USACO 2012 Mar Gold] Large Banner

    传送门:http://www.usaco.org/index.php?page=viewproblem2&cpid=127 又是一道这种题目,遇到一次跪一次,这次终于硬着头皮看懂了题解,但是谢 ...

  8. [USACO 2012 Feb Gold] Cow Coupons【贪心 堆】

    传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=118 传送门2:http://www.lydsy.com/JudgeOn ...

  9. bzoj258 [USACO 2012 Jan Gold] Bovine Alliance【巧妙】

    传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=111 传送门2:http://www.lydsy.com/JudgeOn ...

随机推荐

  1. 夺命雷公狗-----tp中遇到数据乘积的问题的遇见

    昨晚遇到了一个很神奇的问题, 然后打印出来的结果是 ) LIMIT , 然后dump出来的结果有点无语,他是10*10这样的倍增的,如果数据量大,分分钟直接可以让服务器直接死掉.... 想这问题我想了 ...

  2. HGE游戏引擎之hgeQuad结构体的使用(用于渲染图片)

    HGE基本的渲染图元是hgeQuad (Quad is the basic HGE graphic primitive),其中有一个hgeVertex成员结构,它用来描述图元顶点信息.The hgeV ...

  3. QTP11.00安装+破解详细教程

    一.      安装过程 首先双击setup.exe文件,选择“QuickTest Professional安装程序” 此时会查看你机子上面是否有QTP需要,但是机子上没有的组件, 跟着先安装这两个组 ...

  4. jsp页面的跳转取值

    <p >工单管理 >> <c:if test="${code eq 0}">全部工单>>详情页</c:if> <c ...

  5. 【python cookbook】【数据结构与算法】14.对不原生支持比较操作的对象排序

    问题:想在同一个类的实例之间做排序,但是它们并不原生支持比较操作. 解决方案:使用内建的sorted()函数可接受一个用来传递可调用对象的参数key,sorted利用该可调用对象返回的待排序对象中的某 ...

  6. scala的apply方法

    package com.test.scala.test /** * apply 方法 */ object ApplyTest { def main(args: Array[String]): Unit ...

  7. JVM学习笔记(二)------Java代码编译和执行的整个过程【转】

    转自:http://blog.csdn.net/cutesource/article/details/5904542 版权声明:本文为博主原创文章,未经博主允许不得转载. Java代码编译是由Java ...

  8. Java生产者消费者模型

    在Java中线程同步的经典案例,不同线程对同一个对象同时进行多线程操作,为了保持线程安全,数据结果要是我们期望的结果. 生产者-消费者模型可以很好的解释这个现象:对于公共数据data,初始值为0,多个 ...

  9. nexus启动不了

    nexus一分钟前还能正常启动,突然就启动不了,看了下启动文件,变成0KB就知道什么问题了,文件被系统洗了. 解决方案:重新解压缩文件包里复制一个过来.

  10. 配置SecondaryNameNode

    一.SecondaryNameNode概念: 光从字面上来理解,很容易让一些初学者先入为主:SecondaryNameNode(snn)就是NameNode(nn)的热备进程.其实不是.ssn是HDF ...