2012 #5 Gold miner

來源:互聯網
上載者:User

標籤:

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 DescriptionHomelesser 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. 

 

InputThere 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) 

 

OutputPrint the case number and the maximum value for each test case. 

 

Sample Input3 101 1 1 12 2 2 21 3 15 93 101 1 13 12 2 2 21 3 4 7 

 

Sample OutputCase 1: 3Case 2: 7 

 

AuthorHIT 

 

Source2012 Multi-University Training Contest 5 

 

Recommendzhuyuanchen520
  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

 

2012 #5 Gold miner

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.