"Hdoj" 4341 Gold Miner

Source: Internet
Author: User

Group 01 backpacks. The points in a line are grouped together.

1 /*4341*/2#include <iostream>3#include <sstream>4#include <string>5#include <map>6#include <queue>7#include <Set>8#include <stack>9#include <vector>Ten#include <deque> One#include <algorithm> A#include <cstdio> -#include <cmath> -#include <ctime> the#include <cstring> -#include <climits> -#include <cctype> -#include <cassert> +#include <functional> -#include <iterator> +#include <iomanip> A using namespacestd; at //#pragma COMMENT (linker, "/stack:102400000,1024000") -  - #defineSTI set<int> - #defineStpii Set<pair<int, int> > - #defineMpii map<int,int> - #defineVI vector<int> in #definePII pair<int,int> - #defineVpii vector<pair<int,int> > to #defineRep (I, A, n) for (int i=a;i<n;++i) + #definePer (i, a, n) for (int i=n-1;i>=a;--i) - #defineCLR Clear the #definePB Push_back * #defineMP Make_pair $ #defineFIR FirstPanax Notoginseng #defineSEC Second - #defineAll (x) (x). Begin (), (x). End () the #defineSZ (x) ((int) (x). Size ()) + #defineLson L, Mid, rt<<1 A #defineRson mid+1, R, rt<<1|1 the  +typedefstructmine_t { -     intx, y, T, V; $      $FriendBOOL operator< (Constmine_t& A,Constmine_t&b) { -         intTMP = a.x * B.Y-A.Y *b.x; -         if(TMP! =0) the             returnTMP <0; -         returnA.y <b.y;Wuyi     } the } mine_t; -  Wu Const intMAXN =205; - Const intMaxt =40005; About mine_t MINE[MAXN]; $ intDp[maxt]; - intB[MAXN][MAXN]; - intSZ[MAXN]; - intN, T; A  + BOOLcmpinti) { the     returni+1<n && mine[i].x*mine[i+1].y==mine[i].y*mine[i+1].x; - } $  the voidsolve () { the     intbn =0; the      theSort (mine, mine+n); -memset (SZ,0,sizeof(SZ)); inRep (I,0, N) { theb[bn][sz[bn]++] =i; the         if(CMP (i)) { Aboutmine[i+1].t + =mine[i].t; themine[i+1].V + =mine[i].v; the}Else { the++Bn; +         } -     } the     BayiMemset (DP,0,sizeof(DP)); theRep (I,0, BN) { thePer (J,0, t+1) { -Rep (K,0, Sz[i]) { -                 intID =B[i][k]; the                 intt =mine[id].t; the                 intv =mine[id].v; the                 if(J >=t) theDP[J] = max (Dp[j], dp[j-t]+v); -             } the         } the     } the     94     intAns =Dp[t]; theprintf"%d\n", ans); the } the 98 intMain () { AboutIos::sync_with_stdio (false); - #ifndef Online_judge101Freopen ("data.in","R", stdin);102Freopen ("Data.out","W", stdout);103     #endif104      the     intt =0;106     107      while(SCANF ("%d%d", &n, &t)! =EOF) {108Rep (I,0, N)109scanf"%d %d%d%d", &mine[i].x, &mine[i].y, &mine[i].t, &mine[i].v); theprintf"Case %d:", ++t);111 solve ();  the     }113      the #ifndef Online_judge theprintf"Time =%d.\n", (int) clock ()); the     #endif117     118     return 0;119}

Data generators.

1  fromCopyImportdeepcopy2  fromRandomImportRandint, Shuffle3 ImportShutil4 Importstring5 6 7 defGendatain ():8With open ("data.in","W") as Fout:9t = 20Tenbound = 10**5 OneLD =list (string.digits) A         #fout.write ("%d\n"% (t)) -          forTtinchxrange (t): -n = randint (1, 200) theT = Randint (1, 200**2) -Fout.write ("%d%d\n"%(n, T)) -              forIinchxrange (n): -x = Randint (-200, 200) +y = randint (0, 200) -t = Randint (1, 200) +v = randint (0, 200) AFout.write ("%d %d%d%d\n"%(x, y, T, v)) at              -                  - defMovdatain (): -Desfilename ="F:\eclipse_prj\workspace\hdoj\data.in" -Shutil.copyfile ("data.in", Desfilename) -  in      - if __name__=="__main__": to Gendatain () +Movdatain ()

"Hdoj" 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.