1 /**************************************************************
2 Problem: 4004
3 User: Tunix
4 Language: C++
5 Result: Accepted
6 Time:896 ms
7 Memory:3840 kb
8 ****************************************************************/
9
10 //Huce #5 C
11 #include<cmath>
12 #include<vector>
13 #include<cstdio>
14 #include<cstdlib>
15 #include<cstring>
16 #include<iostream>
17 #include<algorithm>
18 #define rep(i,n) for(int i=0;i<n;++i)
19 #define F(i,j,n) for(int i=j;i<=n;++i)
20 #define D(i,j,n) for(int i=j;i>=n;--i)
21 using namespace std;
22
23 int getint(){
24 int v=0,sign=1; char ch=getchar();
25 while(ch<‘0‘||ch>‘9‘) {if (ch==‘-‘) sign=-1; ch=getchar();}
26 while(ch>=‘0‘&&ch<=‘9‘) {v=v*10+ch-‘0‘; ch=getchar();}
27 return v*sign;
28 }
29 typedef long long LL;
30 const int N=510,INF=~0u>>2;
31 const double eps=1e-5;
32 /*******************tamplate********************/
33 int n,m,base[N],ans,sum;
34 struct data{int c;double z[N];}a[N];
35 inline bool cmp(data a,data b){return a.c<b.c;}
36 int main(){
37 #ifndef ONLINE_JUDGE
38 freopen("input.txt","r",stdin);
39 // freopen("output.txt","w",stdout);
40 #endif
41 n=getint(); m=getint();
42 F(i,1,n) F(j,1,m) a[i].z[j]=getint();
43 F(i,1,n) a[i].c=getint();
44 sort(a+1,a+n+1,cmp);
45 F(i,1,n){
46 F(j,1,m) if (fabs(a[i].z[j])>eps){
47 if (!base[j]){
48 base[j]=i;
49 ans++; sum+=a[i].c;
50 break;
51 }else{
52 double t=a[i].z[j]/a[base[j]].z[j];
53 F(k,j,m) a[i].z[k]-=a[base[j]].z[k]*t;
54 }
55 }
56 }
57 printf("%d %d\n",ans,sum);
58 return 0;
59 }