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. MyEclipse 死掉,JVM terminated. Exit code=1073807364

    刚入手的新成员,刚开始使用myeclipse,是不是会有一大堆的问题,然后没有目标的走,这里有个小技巧,那就是如果做项目出现问题,一定要自己现在网络搜寻答案,网络时代.技术时代走到现在,一定有他的道理 ...

  2. 关于wxwidgets图形界面的关闭窗口的按钮无效的解决办法

    这是使用wxsmith设计界面时的情况,如果用纯代码写的界面,关闭按钮就很奇怪地有效 道听途说,窗口的关闭是由一个方法控制着.大概是这样的: void PlainFrame::OnClose(wxCl ...

  3. MapReduce:详解Shuffle过程

    Shuffle过程是MapReduce的核心,也被称为奇迹发生的地方.要想理解MapReduce, Shuffle是必须要了解的.我看过很多相关的资料,但每次看完都云里雾里的绕着,很难理清大致的逻辑, ...

  4. 使用Json.Net处理json序列化和反序列化接口或继承类

    以前一直没有怎么关注过Newtonsoft的Json.Net这个第三方的.NET Json框架,主要是我以前在开发项目的时候大多数使用的都是.NET自带的Json序列化类JavaScriptSeria ...

  5. Xml游标

    Mainactivity package com.exmple.xmlstream; import java.util.ArrayList; import java.util.List; import ...

  6. android 学习随笔六(网络要求及配置)

    android在4.0之后已经不允许在主线程执行http请求了. 主线程阻塞,应用会停止刷新界面,停止响应用户任何操作,耗时操作不要写在主线程   只有主线程才能修改UI ANR异常:Applicat ...

  7. datasnap 的线程池(转)

    datasnap的线程池 新的datasnap使用INDY10的线程池.不管你知不知道,DATASNAP都是使用线程池了,这和MIDAS不同,MIDAS默认是没有线程池的. 跟踪INDY10线程池类T ...

  8. JSP:一种服务器端动态页面技术的组件规范。

    java Servlet page:java服务器端页面,会增加服务器的压力. jsp文件会被容器转换成一个Servlet类然后执行. JSP页面中的注释: HTML注释:<!-- 注释中的ja ...

  9. Linux设备驱动之semaphore机制【转】

    转自:http://blog.csdn.net/xiao229404041/article/details/7031776 Linux设备驱动之semaphore机制在Linux系统中,信号号是一种重 ...

  10. java对象的序列化与反序列化使用

    1.Java序列化与反序列化  Java序列化是指把Java对象转换为字节序列的过程:而Java反序列化是指把字节序列恢复为Java对象的过程. 2.为什么需要序列化与反序列化 我们知道,当两个进程进 ...