Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The vaccination team will divide themselves into two teams and will sit in two different cars. Consider that your society is a grid of NM

The vaccination team will divide themselves into two teams and will sit in two different cars. Consider that your society is a grid of NM houses. Each house has a certain number of family members. Let the number of family members in (i,j) house be familyMembers [i] [j]. Now, the two cars with Vaccination staff are parked at the house (1,1) and (1,M) respectively. Every hour, the cars will move one step ahead. The car will vaccinate all the familyMembers of the house they visit (Note that a family member can not be vaccinated twice). The condition of movement of cars is that the cars can move only in 3 directions. From house (i,j), a car can move to house (i+1,j),(i+1,j1) and (i+1,j + 1). Also, cars can not move outside society. The orocess will continue till the cars are stuck and cannot nove ahead. Now, you want to get as many geople as possible to be vaccinated. Therefore, you are wondering to guide the cars in a way that maximizes the number of people vaccinated. Output the maximum number of people that can get the vaccine. INPUTFORMAT: The first line of input contains an integer N. The second line of input contains an integer M. Next N lines contain M space-separated integers denoting familyMembers[i][j]. SAMPLE INPUT #1: 4 4 1221 52102 31551 111 SAMPLE OUTPUT #1: 39 N=4,M=4, familyMembers =[[1,2,2,1],[5,2,10 2],[3,15,5,1],[1,1,1,1]] The car #1 can take the following route - (1,1)(2, 1) (3,2)(4,1). Number of people vaccinated =1 +5+15+1=22 The car #2 can take the following route - (1,4)(2, 3) (3,3)(4,2). Number of people vaccinated =1 +10+5+1=17 Total number of people vaccinated =22+17=39 : Therefore, the answer is 39. Swift Language Solution

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

2. What should an employer do when facing an OSHA inspection?

Answered: 1 week ago