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 ...
随机推荐
- 经典SQL
一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份sql server--- 创建 备 ...
- java.io.DataInput接口和java.io.DataOutput接口详解
public interface DataInput DataInput 接口用于从二进制流中读取字节,并重构所有 Java 基本类型数据.同时还提供根据 UTF-8 修改版格式的数据重构 Strin ...
- Linux Centos 上一些常用的命令
1.查看端口被哪个进程占用 netstat -lnp | grep <端口号> 2.查看某个进程号详细信息 ps <进程号> 3.检查指定服务是否开启(例如 telnet) c ...
- PHP json_decode object时报错Cannot use object of type stdClass as array
PHP json_decode object时报错Cannot use object of type stdClass as array php再调用json_decode从字符串对象生成json对象 ...
- 深入研究java.lang.Runtime类【转】
转自:http://blog.csdn.net/lastsweetop/article/details/3961911 目录(?)[-] javalang 类 Runtime getRuntime e ...
- php const define 区别有那些呢?
(1) 编译器处理方式不同 define宏是在预处理阶段展开. const常量是编译运行阶段使用. (2) 类型和安全检查不同 define宏没有类型,不做任何类型检查,仅仅是展开. const常量有 ...
- Json常见问题
1.创建包含 JSON 语法的 JavaScript 字符串: var txt = '{ "employees" : [' + '{ "firstName":& ...
- Postgres-XL集群搭建
Postgres-XL 是一个完全满足ACID的.开源的.可方便进行水平扩展的.多租户安全的.支持share-nothing;支持海量数据并行处理-MPP(Massively Parallel Pro ...
- hdwiki 框架简介
虽然HDwiki是一个开源的wiki系统,并且代码简洁易懂,但如果想在系统上做做进一步开发还需要对框架有一个整体的认识.熟悉了HDwiki的框架以后完全可以独立出来做其他功能的开发,当做一个开源的PH ...
- C类地址
C类地址第1字节.第2字节和第3个字节为网络地址,第4个字节为主机地址.另外第1个字节的前三位固定为110. C类地址范围:192.0.0.1到223.255.255.255.(第1个字节的二进制值前 ...