Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 5 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 17 Sep 2017 My Price 7.00

infinite amount of fire trucks

James Moriarty started fire at M places in London. Sherlock Holmes has been called to help extinguish the fires as quickly as possible. There are exactly N fire stations in the city, each having infinite amount of fire trucks. But the time taken by each fire station to fill a truck is different and the fire stations can only fill one truck at a time. Initially all the fire trucks are empty.

Given the time taken by each fire station to fill one truck and the time taken for a fire truck to reach the jthplace from the ith fire station, Sherlock needs to tell the minimum time taken to extinguish the fire at all places.

Input

First line contains T,(T

Each line of first test case contains two integers N and M,(N,M

Next line contains N space separated integers, where the ith integer denotes the time taken (1th fire station to fill one truck.

Then next N lines will follow, each containing M integers, where the integer at ith row and jth column denotes the time taken (1th fire station to reach jth place.

Output

Output of each test case is a single line denoting the minimum time required to extinguish the fire completely.

Note

Consider that as soon as a fire truck reaches the place, the fire extinguishes there in no time.

Each place will require exactly one truck to extinguish the fire.

Fire truck once used can not be used again.

There are infinite number of fire trucks at every station.

Example

Input: 1 3 4 2 5 4 1 2 3 1 2 3 1 2 2 2 3 1 Output: 6

Explanation:

The 1st fire station sends trucks to both 1st and 4th place. Time Taken=5

The 2nd fire station sends a truck to 3rd place. Time Taken=6

The 3rd fire station sends a truck to 2nd place. Time Taken=6

Answers

(5)
Status NEW Posted 17 Sep 2017 05:09 AM My Price 7.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)