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. lower power的IP设计

    在IP的实现过程中,考虑lower power部分进行设计: 1)Partition the design来满足lower power的一些strategies,尤其是power gating和clo ...

  2. 关于在windows下使用mingw并行编译wxwidgets时的错误

    清理用的命令:mingw32-make -j4 -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 clean 2>nul ...

  3. 向已写好的多行插入sql语句中添加字段和值

    #region 添加支款方式--向已写好的多行插入sql语句中添加字段和值 public int A_ZhifuFS(int diqu) { ; string strData = @"SEL ...

  4. GitHub Desktop for Win 安装不上

    采用了ClickOnce部署方式,网速不给力,安装过程经常断线,要是有离线安装包就好了.

  5. Intent跳转传list集合

    先把List<>改为ArrayList<> ArrayList<Good> list=new ArrayList<Good>(); Intent int ...

  6. linux设备驱动归纳总结(四):2.进程调度的相关概念【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-65555.html linux设备驱动归纳总结(四):2.进程调度的相关概念 xxxxxxxxxxxx ...

  7. 关于web开发前端h5框架的选择

    关于web开发前端h5框架的选择 看了很多移动版框架都是基于app混合式开发的,不是单独h5网站的基于h5开发的web框架从组件丰富度,兼容性,相关教程来说bootstrap还是最好的react和vu ...

  8. [ios]app后台运行

    参考:http://www.douban.com/note/375127736/ 1 使用开源代码MMPDeepSleepPreventer将文件加入工程,包括音频文件.可以在源文件中加入单例,便于使 ...

  9. java静态块

    一般情况下,如果有些代码必须在项目启动的时候就执行的时候,需要使用静态代码块,这种代码是主动执行的 静态代码块的初始化顺序  class Parent{ static String name = &q ...

  10. java中文件的读取和写入

    //首先要顶一个file文件用来存放要读取的文件 File f=new File("c:/test/aa.txt"); //在实例化一个输入流,并把文件对象传到里面 FileInp ...