标签:
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
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 }
标签:
原文地址:http://www.cnblogs.com/cyd308/p/4771455.html