2012 #5 Gold miner
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

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.
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)
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
Case 2: 7
#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的更多相关文章
- HDU 4341 Gold miner(分组背包)
题目链接 Gold miner 目标是要在规定时间内获得的价值总和要尽可能大. 我们先用并查集把斜率相同的物品分在同一个组. 这些组里的物品按照y坐标的大小升序排序. 如果组内的一个物品被选取了,那该 ...
- HDU-4341 Gold miner 题解
题目大意 黄金矿工的游戏,不过每个金块可以看做是质点,没有大小,给出每个金块的坐标.抓取所花费的时间(包括返回的时间),以及价值,其中有一些金块可能会共线.求在规定时间内所获得的最大价值. 样例 样例 ...
- 【HDOJ】4341 Gold miner
分组01背包.在一条直线上的点归为一组. /* 4341 */ #include <iostream> #include <sstream> #include <stri ...
- 【HDU - 4341】Gold miner(分组背包)
BUPT2017 wintertraining(15) #8B 题意 给出每个黄金的坐标.价值及耗时,同一方向的黄金只能依次取,求T时间内收获的最大值. 题解 同一方向,物品前缀和构成的组合,相当于是 ...
- HDU 4341 Gold miner (分组背包)
先把线按照距离原点的距离排序,然后用叉积把在同一条直线上的点放在一起, 把在同一条线上的点中的前i个点当成一个点就转化成了分组背包. 写if(kas++) putchar('\n') 居然PE了,PE ...
- [USACO 2012 Open Gold] Bookshelf【优化dp】
传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=138 传送门2:http://www.lydsy.com/JudgeOn ...
- [USACO 2012 Mar Gold] Large Banner
传送门:http://www.usaco.org/index.php?page=viewproblem2&cpid=127 又是一道这种题目,遇到一次跪一次,这次终于硬着头皮看懂了题解,但是谢 ...
- [USACO 2012 Feb Gold] Cow Coupons【贪心 堆】
传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=118 传送门2:http://www.lydsy.com/JudgeOn ...
- bzoj258 [USACO 2012 Jan Gold] Bovine Alliance【巧妙】
传送门1:http://www.usaco.org/index.php?page=viewproblem2&cpid=111 传送门2:http://www.lydsy.com/JudgeOn ...
随机推荐
- 手机端js实现滑块推动
代码编写:(写的格式有点差,凑合看吧,但是功能是实现了的) <html><head><meta http-equiv="Content-Type" c ...
- [Ubuntu] google chrome乱码
问题描述 ubuntu14.04,之前google chrome一直都是好好的,升级过相关软件,之后就是乱码了,如图 经过google的努力,找到解决方法,原因未明. 解决方案 sudo /etc/f ...
- SQL——存储过程
1. 为什么使用存储过程 应用程序通过T-SQL语句到服务器的过程是不安全的. 1) 数据不安全 2)每次提交SQL代码都要经过语法编译后在执行,影响应用程序的运行性能 3) 网络流量大 2. 什么是 ...
- Bonbo Git Server
Install This page covers simple Bonobo Git Server installation. Be sure to check prerequisites page ...
- python paramiko ssh.exec_command()启动tomcat服务器应用进程失败问题解决方法- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this progr
问题说明:
- 160902、Ionic、Angularjs、Cordova搭建Android开发环境
1.jdk 环境变量配置 path:C:\Program Files\Java\jdk1.7.0_79\bin 2.node.js 因为安装cordova时要用到node.js的npm 下载地址: h ...
- andoid下的股票行情开发
1.信息类 public class SinaStockInfo { /** * Sina股票数据接口 以大秦铁路(股票代码:601006)为例,如果要获取它的最新行情,只需访问新浪的股票数据 * 接 ...
- Hive报错之java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonFactory
一.问题: 在使用Hive0.11进行select查询的时候报: hive,),site from zhifu; Total MapReduce jobs Launching Job out In o ...
- iOS 第一次安装应用,拒绝相机调用,页面卡死的解决方案
void (^allowBlock)() = ^{ UIImagePickerController *imagePicker = [[UIImagePickerController alloc] in ...
- C# winform 中MessageBox用法大全(附效果图) (转载+说明)
声明:这篇文章是转载的转载的,由于原作者的博客被关闭 我就不再列出了,提前先说明下,if语句中的判断有些太长,建议提前声明一个变量, DialogResult MsgBoxResult; ...