zoukankan      html  css  js  c++  java
  • 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

    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("
    
    ");
     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("
    ");
    106         }
    107         printf("
    ");
    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("
    ");
    115         }
    116         printf("
    ");*/
    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
    ",cas++,ans);
    123     }
    124     return 0;
    125 }
    View Code
  • 相关阅读:
    I.MX6 Manufacturing Tool V2 (MFGTool2) ucl2.xml hacking
    I.MX6 Manufacturing Tool V2 (MFGTool2) Update Command List (UCL) User Guide translate
    I.MX6 Manufacturing Tool V2 (MFGTool2) Emmc mksdcard-android.sh hacking
    I.MX6 Manufacturing Tool V2 (MFGTool2) Emmc mksdcard.sh hacking
    Eclipse中设置在创建新类时自动生成注释
    code
    Oracle的rownum原理和使用(整理几个达人的帖子)
    Catalog与Schema
    对于oracle监听器的配置
    64位WIN7+oracle11g+plsql安装
  • 原文地址:https://www.cnblogs.com/cyd308/p/4771455.html
Copyright © 2011-2022 走看看