#P2095. 营养膳食

营养膳食

Description

Mr. L is working on his weight gain plan.

To gain weight, Mr. L wants to eat more fat. However, he cannot eat only high-fat foods, otherwise he would lack other nutrients.

Through research, Mr. L found that a truly balanced diet sets an upper limit on the number of servings of each category in a single meal. For example, for one meal: at most 11 serving of meat, at most 11 serving of fish, at most 11 serving of eggs, and at most 22 servings of vegetables.

Mr. L wants to maximize fat intake while following a nutritional diet, and of course his capacity is limited.

Input Format

The first line contains three positive integers nn, mm and kk. Here, mm is the maximum number of servings Mr. L can eat in one meal; there are nn foods to choose from, and these nn foods fall into kk categories.

The second line contains kk positive integers, each not exceeding 1010, where the ii-th number gives the maximum number of servings allowed for category ii in a single meal, for categories 11 through kk.

Each of the next nn lines contains 22 positive integers: the fat index aia_i of that food and its category bib_i.

Output Format

Output a single integer: the maximum possible total fat index that Mr. L can eat.

6 6 3
3 3 2
15 1
15 2
10 2
15 2
10 2
5 3
60

Hint

For 100%100\% of the testdata, 1n2001 \leq n \leq 200, 1m1001 \leq m \leq 100, 1k1001 \leq k \leq 100, 1ai1001 \leq a_i \leq 100, 1bik1 \leq b_i \leq k.

Translated by ChatGPT 5