Submit | All submissions | Best solutions | Back to list |
BTCODE_D - Maximum Profit |
Chakra is a young and dynamic entrepreneur, who is developing rapidly as a successful hotelier. He owns the Quickbyte chain of restaurants, 'M' of which are fully functional now. He divides each day into 'N' time slots. For each time slot 'j', in every restaurant 'i', there are Aij waiters and Bij customers. Being a quality conscious person, he wants each waiter to handle at most one customer in a given time slot. Since he is really busy, in a day each restaurant is open only during one of the time slots. Since the hunger and demand for food varies during the day, the price which the customer is willing to pay varies, and is given by Cij for a restaurant 'i' during a time slot 'j'.
Given the values of Aij, Bij and Cij, find the maximum profit which Chakra can make in a day.
Input
The first line of input contains an integer 't', denoting the number of test cases.
For each testcase, the first line contains 2 space separated integers 'M' and 'N'.
Each of the next 'M' lines contains 'N' integers. The jth integer on the ith line denotes the value of Aij.
Each of the next 'M' lines contains 'N' integers. The jth integer on the ith line denotes the value of Bij.
Each of the next 'M' lines contains 'N' integers. The jth integer on the ith line denotes the value of Cij
Output
For each test case output one value, denoting the maximum profit which Chakra can make in a day.
More than one restaurant can be open during a given time slot.
Constraints
t <= 50
1 <= M,N <= 100
1 <= Aij, Bij <= 5000
0 <= Cij <= 10^9
Example
Input: 1 2 3 1 2 3 3 2 1 3 2 1 1 2 3 4 5 2 3 1 6 Output: 16
Explanation
Test case 1: By opening the first restaurant at time slot 2 and second restaurant at time slot 3, Chakra makes a profit = 2*5 + 1*6 = 16. Note that although there are 3 customers for the second restaurant at time slot 3, since there is only 1 waiter, only 1 customer can be served.
Added by: | suhash |
Date: | 2011-02-26 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Bytecode 2011, NIT Trichy, India |
hide comments
|
||||||
2013-07-12 08:33:54 BLANKRK
in fst attempt...:D |
||||||
2013-07-05 17:54:53 ..........
Accepted at one trial:D |
||||||
2013-06-29 15:28:26 Ouditchya Sinha
Trivial! :) |
||||||
2013-06-08 09:41:55 Rishabh Dugar
finally ac Last edit: 2013-06-11 10:00:46 |
||||||
2012-10-16 20:26:34 rb
finally got AC!!! |
||||||
2012-08-22 07:19:59 gabber
use long long int for c++ cost me 3 wa |
||||||
2012-07-18 03:03:43 Bharath Reddy
Extremely simple.. |
||||||
2012-07-11 16:11:56 game2712
thank you acp saab |
||||||
2012-06-01 05:54:59 Pankaj Kumar
do not take any assumptions... |