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