SELLPHN2  Mobile Company 2
On day 1, a mobile manufacturing company bought L quantities of raw materials which can produce exactly L mobile phones. The raw materials are then transported to factories.
The company owns M factories located at various locations where these raw materials are converted into mobile phones. ith factory is capable of producing atmost F[i] mobile phones provided the availability of raw materials.
The manufactured mobile phones can be transported to N shops at various locations where these mobile phones are sold. Each shop has a selling capability. ith shop can sell atmost S[i] mobile phones in a day. You are given a 2D map of order MxN. ith factory can transport atmost map[i][j] mobile phones to jth shop.
Find the maximum number of mobile phones that can be sold by the company on day 1. For simplicity you can assume that the time taken for transportation of raw materials and mobiles as 0.
Input:
The first line consists of an integer t, the number of test cases. For each test case, the first line consists of 3 integers L, M and N. The next line consists of M integers representing the array F. The next line consists of N integers representing the array S. The next M lines represent the map.
Output:
For each test case, find the maximum number of mobile phones that can be sold by the company on day 1.
Input Constraints:
1 <= t <= 100
1 <= L <= 1000
1 <= M <= 200
1 <= N <= 200
0 <= F[i] <= 1000
0 <= S[i] <= 1000
0 <= map[i][j] <= 1000
Sample Input:
1
5 2 2
3 5
2 3
1 2
1 0
Sample Output:
4
See also : Mobile Company 1
hide comments
[Rampage] Blue.Mary:
20160208 11:01:45
You need a fast [spoiler] library, not need to consider time complexity. Last edit: 20160729 21:57:43 

Rishav Goyal:
20150828 13:48:13
what is the expected order in it ? 200^2*1000*T is failing. Last edit: 20150828 13:54:17 

(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
20150530 00:31:29
Finally!! FirstPlace!!! ^_^ 

(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
20150529 23:59:09
phew, finally AC..


Eddy R. Morales Perez:
20150424 22:14:11
My 700th classical ;) 

785227:
20150407 14:42:31
My 300th classical, A milestone problem _/\_ 
Added by:  cegprakash 
Date:  20150114 
Time limit:  10s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: BF 