1 #include<cstdio>
2
3 #include<cstdlib>
4
5 #include<cmath>
6
7 #include<cstring>
8
9 #include<algorithm>
10
11 #include<iostream>
12
13 #include<vector>
14
15 #include<map>
16
17 #include<set>
18
19 #include<queue>
20
21 #include<string>
22
23 #define inf 1000000000
24
25 #define maxn 200000+5
26
27 #define maxm 200000+5
28
29 #define eps 1e-10
30
31 #define ll long long
32
33 #define pa pair<int,int>
34
35 #define for0(i,n) for(int i=0;i<=(n);i++)
36
37 #define for1(i,n) for(int i=1;i<=(n);i++)
38
39 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
40
41 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
42
43 #define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
44
45 #define for5(n,m) for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
46
47 #define mod 1000000007
48
49 using namespace std;
50
51 inline int read()
52
53 {
54
55 int x=0,f=1;char ch=getchar();
56
57 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
58
59 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}
60
61 return x*f;
62
63 }
64 int n,m,k,mincost,tot=1,a[maxn],s,t,head[maxn],d[maxn],from[2*maxm];
65
66 bool v[maxn];
67
68 queue<int>q;
69
70 struct edge{int from,go,next,v,c;}e[2*maxm];
71
72 void add(int x,int y,int v,int c)
73
74 {
75
76 e[++tot]=(edge){x,y,head[x],v,c};head[x]=tot;
77
78 e[++tot]=(edge){y,x,head[y],0,-c};head[y]=tot;
79
80 }
81
82 bool spfa()
83
84 {
85
86 for (int i=s;i<=t;i++){v[i]=0;d[i]=inf;}
87
88 q.push(s);d[s]=0;v[s]=1;
89
90 while(!q.empty())
91
92 {
93
94 int x=q.front();q.pop();v[x]=0;
95
96 for (int i=head[x],y;i;i=e[i].next)
97
98 if(e[i].v&&d[x]+e[i].c<d[y=e[i].go])
99
100 {
101
102 d[y]=d[x]+e[i].c;from[y]=i;
103
104 if(!v[y]){v[y]=1;q.push(y);}
105
106 }
107
108 }
109
110 return d[t]!=inf;
111
112 }
113
114 void mcf()
115
116 {
117
118 mincost=0;
119
120 while(spfa())
121
122 {
123
124 int tmp=inf;
125
126 for(int i=from[t];i;i=from[e[i].from]) tmp=min(tmp,e[i].v);
127
128 mincost+=d[t]*tmp;
129
130 for(int i=from[t];i;i=from[e[i].from]){e[i].v-=tmp;e[i^1].v+=tmp;}
131
132 }
133
134 }
135
136 int main()
137
138 {
139
140 freopen("input.txt","r",stdin);
141
142 freopen("output.txt","w",stdout);
143
144 n=read();m=read();k=read();s=0;t=n+m+1;
145 for1(i,m)
146 {
147 int x=read();
148 for1(j,n)add(n+i,t,1,(2*j-1)*x);
149 }
150 for1(i,m)a[i]=read();
151 for1(i,n)for1(j,m)
152 {
153 char ch=getchar();
154 while(ch!=‘0‘&&ch!=‘1‘)ch=getchar();
155 if(ch==‘1‘)add(i,n+j,1,-a[j]);
156 }
157 for1(i,n)add(s,i,k,0);
158 if(k-1)for1(i,n)add(i,t,k-1,0);
159 mcf();
160 cout<<mincost<<endl;
161
162 return 0;
163
164 }