#P4209. 学习小组

学习小组

Description

There are nn students and mm study groups. Each student is willing to join only some of the study groups, and any student can join at most kk study groups. For each student participating in a study group, the finance office charges a handling fee; different study groups have different fees. If aa students join the ii-th study group, the finance office pays a reward of Ci×a2C_i \times a^2 yuan. Subject to making the number of participating students (i.e., the number of distinct students, not the sum over all groups) as large as possible, find the minimum amount of money the finance office must spend.

Input Format

The input consists of multiple lines. The first line contains three positive integers n,m,kn, m, k separated by spaces.

The next line contains mm positive integers, the values of CiC_i.

The third line contains mm positive integers, the handling fees FiF_i required to join each study group.

Then follows an nn-by-mm matrix. If the number at row ii, column jj is 1, then the ii-th student is willing to join the jj-th study group; if it is 0, then the student is unwilling.

Output Format

Output a single integer: the minimum expenditure.

3 3 1
1 2 3
3 2 1
111
111
111
-2

Hint

For 100%100\% of the testdata, 0<n1000 < n \le 100, 0<m900 < m \le 90, 0<km0 < k \le m, 0<Ci100 < C_i \le 10, 0<Fi1000 < F_i \le 100.

Translated by ChatGPT 5