HDU 4341 Gold Miner

Source: Internet
Author: User

First, the lines are sorted by distance from the origin, and then the points in the same line are put together with the cross product,

The first point of the point in the same line is treated as a point, which is transformed into a pack backpack.

Write if (kas++) Putchar (' \ n ') actually PE

#include <bits/stdc++.h>using namespacestd;intn,t;Const intMAXN =203;Const intMaxt =40005;structpoint{intX,y,t,v;} P[MAXN];BOOLVis[maxn];vector<int>LINE[MAXN];intline_cnt;#definePB push_backintDot (ConstPoint &a,Constpoint& b) {returna.x*b.x+a.y*b.y;}DoubleLength (ConstPoint &x) {returnsqrt (Dot (x,x));}intCross (Point &a,point &b) {    returna.x*b.y-b.x*a.y;}BOOL operator< (Constpoint& A,ConstPoint & B) {returnLength (a) <Length (b);}voidinit () {memset (Vis,0,sizeof(VIS));  for(inti =0; i < N; i++) {scanf ("%d%d%d%d",&p[i].x,&p[i].y,&p[i].t,&p[i].v); } sort (P,p+N); Line_cnt=0;  for(inti =0; i < N; i++)if(!Vis[i])        {line[line_cnt].clear ();  for(intj = i; J < N; J + +)if(!Vis[j]) {            if(Cross (p[i],p[j]) = =0) {Vis[j]=true; LINE[LINE_CNT].            PB (j); }} line_cnt++; }}intf[2][maxt];voiddp () {Fill (f[0],f[0]+1+t,0); Fill (f[1],f[1]+1+t,0);  for(inti =0; i < line_cnt; i++){        intPre = i&1, cur = pre^1; intTotv =0, Tott =0;  for(intj =0; J < Line[i].size (); J + +) { point& x =P[line[i][j]]; Totv+ = X.V; Tott + =x.t;  for(intK = T; K >= Tott; k--) {F[cur][k]= Max (f[cur][k],f[pre][k-tott]+Totv); }        }         for(intK =0; K <= T; k++) {F[cur][k]=Max (f[cur][k],f[pre][k]); }    }}intMain () {intKas =0;  while(~SCANF ("%d%d",&n,&T))        {init ();        DP (); printf ("Case %d:%d\n", ++kas,max (f[0][t],f[1][t])); }    return 0;}

It was not known how to implement one-dimensional arrays to complement one-dimensional pseudo-code

For all Groups K

For V=v. 0

For all I belong to Group K

F[v]=max{f[v],f[v-c[i]]+w[i]}

HDU 4341 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.