#5 Gold Miner

Source: Internet
Author: 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

SubmitStatusPracticeHDU 4341

Problem Descriptionhomelesser likes playing Gold miners in class. He has to pay much attention to the teacher to avoid being noticed. So he is always lose the game. After the losing many times, he wants your help.

To make it easy, the gold becomes a point (with the area of 0). You is given each gold ' s position, the time spent to get this gold, and the value of this gold. Maybe some pieces of gold is co-line, you can only get these pieces in order. Can assume it can turn to any direction immediately.
Please help Homelesser get the maximum value.

Inputthere is multiple cases.
The first line contains and integers N (the number of pieces of gold), T (the total time). (0<n≤200, 0≤t≤40000)
In all of the next N lines, there four integers x, y (the position of the gold), T (the time to get this gold), V (the VA Lue 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 namespacestd;6 7 structNode8 {9     intx;Ten     inty; One     intT; A     intv; -}a[205]; -  the BOOLCMP (Node pp,node QQ) - { -     Doublepx,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-8)) +     { A         returnATAN2 (Px,py) <atan2 (qx,qy); at     } -     Else -     { -         return(Px*px+py*py) < (qx*qx+qy*qy); -     } - } in  - BOOLCompare (Node pp,node QQ) to { +     Doublepx,py,qx,qy; -Px= (Double) pp.x,py= (Double) pp.y; theQx= (Double) qq.x,qy= (Double) qq.y; *     if(Fabs (atan2 (px,py)-atan2 (qx,qy)) <= (1e-8)) $         return true;Panax Notoginseng     Else -         return false; the } +  A intdp[205][40005],coc[205][40005]; the  + intMain () - { $     intn,t,cas=1; $     inti,j,k; -     intb[205]; -      while(SCANF ("%d%d", &n,&t)! =EOF) the     { -memset (b,0,sizeof(b)); Wuyi          for(i=1; i<=n;i++) thescanf"%d %d%d%d",&a[i].x,&a[i].y,&a[i].t,&a[i].v); -Sort (A +1, a+n+1, CMP); Wu          for(i=1; i<n;i++) -         { About              for(j=i+1; j<=n;j++) $             { -                 if(compare (A[i],a[j])) -b[i]++; -                 Else A                      Break; +             } the         } -          for(i=0; i<=n;i++) $         { the              for(j=0; j<=t;j++) the             { thedp[i][j]=0; thecoc[i][j]=0; -             } in         } the  the          for(i=1; i<=n;i++) About         { the              for(j=0; j<=t;j++) the             { thedp[i][j]=Coc[i][j]; +             } -  the              for(j=0; j+a[i].t<=t;j++)Bayi             { theDp[i][j+a[i].t]=max (dp[i][j+a[i].t],coc[i][j]+a[i].v); the                 if(b[i]>0) -                 { -coc[i+1][j+a[i].t]=max (coc[i+1][j+a[i].t],coc[i][j]+a[i].v); the                 } the             } the  the              for(j=0; j<=t;j++) -             { theDp[i][j]=max (dp[i-1][j],dp[i][j]); thecoc[i+b[i]+1][j]=max (coc[i+b[i]+1][j],dp[i][j]); the             }94         } the  the         /*For (i=1;i<=n;i++) the printf ("%d", a[i].v);98 printf ("\ n"); About For (i=1;i<=n;i++) -         {101 For (j=1;j<=t;j++)102             {103 printf ("%d", coc[i][j]);104             } the printf ("\ n");106         }107 printf ("\ n");108 For (i=1;i<=n;i++)109         { the For (j=1;j<=t;j++)111             { the printf ("%d", dp[i][j]);113             } the printf ("\ n"); the         } the printf ("\ n");*/117 118         intans=0;119              for(j=0; j<=t;j++) -                 if(dp[n][j]>ans)121ans=Dp[n][j];122printf"Case %d:%d\n", cas++, ans);123     }124     return 0; the}
View Code

#5 Gold Miner

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.