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

Submit  Status  Practice  HDU 4341

 

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
  1 #include <stdio.h>
  2 #include <string.h>
  3 #include <cmath>
  4 #include <algorithm>
  5 using namespace std;
  6 
  7 struct Node 
  8 {
  9     int x;
 10     int y;
 11     int t;
 12     int v;
 13 }a[205];
 14 
 15 bool cmp(Node pp,Node qq)
 16 {
 17     double px,py,qx,qy;
 18     px=(double)pp.x,py=(double)pp.y;
 19     qx=(double)qq.x,qy=(double)qq.y;
 20     if(fabs(atan2(px,py)-atan2(qx,qy))>(1e-8))
 21     {
 22         return atan2(px,py)<atan2(qx,qy);
 23     }
 24     else
 25     {
 26         return (px*px+py*py)<(qx*qx+qy*qy);
 27     }
 28 }
 29 
 30 bool compare(Node pp,Node qq)
 31 {
 32     double px,py,qx,qy;
 33     px=(double)pp.x,py=(double)pp.y;
 34     qx=(double)qq.x,qy=(double)qq.y;
 35     if(fabs(atan2(px,py)-atan2(qx,qy))<=(1e-8))
 36         return true;
 37     else
 38         return false;
 39 }
 40 
 41 int dp[205][40005],coc[205][40005];
 42 
 43 int main()
 44 {
 45     int n,T,cas=1;
 46     int i,j,k;
 47     int b[205];
 48     while(scanf("%d %d",&n,&T)!=EOF)
 49     {
 50         memset(b,0,sizeof(b));    
 51         for(i=1;i<=n;i++)
 52             scanf("%d %d %d %d",&a[i].x,&a[i].y,&a[i].t,&a[i].v);
 53         sort(a+1,a+n+1,cmp);
 54         for(i=1;i<n;i++)
 55         {
 56             for(j=i+1;j<=n;j++)
 57             {
 58                 if(compare(a[i],a[j]))
 59                     b[i]++;
 60                 else
 61                     break;
 62             }
 63         }
 64         for(i=0;i<=n;i++)
 65         {
 66             for(j=0;j<=T;j++)
 67             {
 68                 dp[i][j]=0;
 69                 coc[i][j]=0;
 70             }
 71         }
 72 
 73         for(i=1;i<=n;i++)
 74         {
 75             for(j=0;j<=T;j++)
 76             {
 77                 dp[i][j]=coc[i][j];
 78             }
 79 
 80             for(j=0;j+a[i].t<=T;j++)
 81             {
 82                 dp[i][j+a[i].t]=max(dp[i][j+a[i].t],coc[i][j]+a[i].v);
 83                 if(b[i]>0)
 84                 {
 85                     coc[i+1][j+a[i].t]=max(coc[i+1][j+a[i].t],coc[i][j]+a[i].v);
 86                 }
 87             }
 88 
 89             for(j=0;j<=T;j++)
 90             {
 91                 dp[i][j]=max(dp[i-1][j],dp[i][j]);
 92                 coc[i+b[i]+1][j]=max(coc[i+b[i]+1][j],dp[i][j]);
 93             }
 94         }
 95 
 96         /*for(i=1;i<=n;i++)
 97             printf("%d ",a[i].v);
 98         printf("\n\n");
 99         for(i=1;i<=n;i++)
100         {
101             for(j=1;j<=T;j++)
102             {
103                 printf("%d ",coc[i][j]);
104             }
105             printf("\n");
106         }
107         printf("\n");
108         for(i=1;i<=n;i++)
109         {
110             for(j=1;j<=T;j++)
111             {
112                 printf("%d ",dp[i][j]);
113             }
114             printf("\n");
115         }
116         printf("\n");*/
117 
118         int ans=0;
119             for(j=0;j<=T;j++)
120                 if(dp[n][j]>ans)
121                     ans=dp[n][j];
122         printf("Case %d: %d\n",cas++,ans);
123     }
124     return 0;
125 }
View Code

 

转载于:https://www.cnblogs.com/cyd308/p/4771455.html

(1)普通用户端(全平台) 音乐播放核心体验: 个性化首页:基于 “听歌历史 + 收藏偏好” 展示 “推荐歌单(每日 30 首)、新歌速递、相似曲风推荐”,支持按 “场景(通勤 / 学习 / 运动)” 切换推荐维度。 播放页功能:支持 “无损音质切换、倍速播放(0.5x-2.0x)、定时关闭、歌词逐句滚动”,提供 “沉浸式全屏模式”(隐藏冗余控件,突出歌词与专辑封面)。 多端同步:自动同步 “播放进度、收藏列表、歌单” 至所有登录设备(如手机暂停后,电脑端打开可继续播放)。 音乐发现与管理: 智能搜索:支持 “歌曲名 / 歌手 / 歌词片段” 搜索,提供 “模糊匹配(如输入‘晴天’联想‘周杰伦 - 晴天’)、热门搜索词推荐”,结果按 “热度 / 匹配度” 排序。 歌单管理:创建 “公开 / 私有 / 加密” 歌单,支持 “批量添加歌曲、拖拽排序、一键分享到社交平台”,系统自动生成 “歌单封面(基于歌曲风格配色)”。 音乐分类浏览:按 “曲风(流行 / 摇滚 / 古典)、语言(国语 / 英语 / 日语)、年代(80 后经典 / 2023 新歌)” 分层浏览,每个分类页展示 “TOP50 榜单”。 社交互动功能: 动态广场:查看 “关注的用户 / 音乐人发布的动态(如‘分享新歌感受’)、好友正在听的歌曲”,支持 “点赞 / 评论 / 转发”,可直接点击动态中的歌曲播放。 听歌排行:个人页展示 “本周听歌 TOP10、累计听歌时长”,平台定期生成 “全球 / 好友榜”(如 “好友中你本周听歌时长排名第 3”)。 音乐圈:加入 “特定曲风圈子(如‘古典音乐爱好者’)”,参与 “话题讨论(如‘你心中最经典的钢琴曲’)、线上歌单共创”。 (2)音乐人端(创作者中心) 作品管理: 音乐上传:支持 “无损音频(FLAC/WAV)+ 歌词文件(LRC)+ 专辑封面” 上传,填写 “歌曲信息
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值