Bzoj 4004: [JLOI2015] Equipment purchase quasi-array && high extinction

Source: Internet
Author: User

4004: [JLOI2015] Equipment purchase time limit:20 Sec Memory limit:128 MB
submit:337 solved:139
[Submit] [Status] [Discuss] Description

Face brother recently playing a magical game, this game has n pieces of equipment, each equipped with m properties, with Vector zi (AJ,....., am) expressed (1 <= i <= n; 1 <= J <= m), each equipment needs to spend CI, now face brother want to buy some clothes , but the elder brother is very poor, so always figuring out how to spend as little as possible to buy as much equipment. For the elder brother, if the property of a piece of equipment can be combined with the other equipment purchased (that is, the elder brother can use the equipment on the hand to assemble the effect of the equipment), then this equipment will not buy the necessary. Strict definition is, if the face brother bought Zi1,..... zip this P-piece equipment, then for any pending decision EN, there is no B1,...., bp make B1zi1 + ... + bpzip = zh (b is real), then face brother will buy zh, otherwise zh Facebook brother is useless , nature does not have to buy. For example, Z1 = (1; 2; 3); z2 = (3; 4; 5); zh = (2; 3; 4), B1 =1/2,b2 =1/2, there is b1z1 + b2z2 = zh, then if the face brother bought Z1 and Z2 will not buy zh. Brother-in-the-face wants to spend the least amount of money in the case of buying the most equipment, can you help him to calculate it?

Input

The first line is two numbers n;m.

The next n rows, the number of M per line, where line I describes the property values of the equipment I. The next line is the number of N, where CI represents the cost of purchasing item I equipment. Output

A row of two numbers, the first number indicates the maximum number of items that can be purchased, and the second number represents the maximum number of installed

The minimum cost of the prepared case. Sample Input3 3
1 2 3
3 4 5
2 3 4
1 1 2Sample Output2 2HINT

As described in the title, choose Equipment 1 Equipment 2, equipment 1 equipment 3, equipment 2 equipment 3 are available, but choose equipment 1 and

The cost of equipping 2 is minimal, at 2.

For 100% data, 1 <= n;m <= 500; 0 <= AJ <= 1000.

@idy002 No EPS can still be a la la La.

#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cassert>using namespacestd;#defineMAXN 510#defineMOD 1000000007typedefLong LongQword;structitem{intA[MAXN]; intv;} LST[MAXN];BOOLCmp_lst (Constitem& L1,Constitem&L2) {        returnl1.v<L2.V;} Qword MAT[MAXN][MAXN];inttotm=0; Qword pow_mod (Qword X,qword y) {qword ret=1;  while(y) {if(y&1) ret=ret*x%MOD; X=x*x%MOD; Y>>=1; }        returnret;}intMain () {Freopen ("Input.txt","R", stdin); intn,m,x,y,z; scanf ("%d%d",&n,&m);  for(intI=0; i<n;i++)                 for(intj=0; j<m;j++) scanf ("%d",&Lst[i].a[j]);  for(intI=0; i<n;i++) scanf ("%d",&lst[i].v); Sort (Lst,lst+n,cmp_lst); intans1=0, ans2=0;  for(intI=0; i<n;i++)        {                 for(intj=0; j<m;j++) Mat[totm][j]=Lst[i].a[j];  for(intj=0; j<totm;j++) {x=0;  for(intk=0; k<m;k++) {x=K; if(Mat[j][k]) Break; } Qword T=mat[totm][x]/Mat[j][x];  for(intk=0; k<m;k++) Mat[totm][k]= (mat[totm][k]-mat[j][k]*t)%MOD; }                BOOLflag=false;  for(intj=0; j<m;j++) {flag|=Mat[totm][j]; if(flag) Break; }                if(!flag)Continue; Ans1++; Ans2+=lst[i].v; X=0;  for(intj=0; j<m;j++) {x=J; if(Mat[totm][j]) Break; } Qword T=pow_mod (mat[totm][x],mod-2);  for(intj=0; j<m;j++) Mat[totm][j]=mat[totm][j]*t%MOD;  for(intJ=totm;j>0; j--)                {                        BOOLFlag;  for(intk=0; k<m;k++)                        {                                if(mat[j-1][k] | |Mat[j][k]) {Assert (! (mat[j-1][K] &&mat[j][k])); if(mat[j-1][k]) {flag=false; }Else{flag=true; }                                         Break; }                        }                        if(!flag) Break;  for(intk=0; k<m;k++) Swap (Mat[j-1][k],mat[j][k]); } TOTM++; } printf ("%d%d\n", ans1,ans2);}

Bzoj 4004: [JLOI2015] Equipment purchase quasi-array && high extinction

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.