Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Ex 2 . Ma 3 moul 3 0 pointsOverviewIt is Eid Alfitr and you can't help but think of your two major fears:Feeling sick because
Ex Mamoul pointsOverviewIt is Eid Alfitr and you can't help but think of your two major fears:Feeling sick because of eating lots of mamoul.Going bankrupt because of giving away too much money.Therefore, you made a map for the houses on the road from your house to your grandparents house, which shows all the houses on the way that you have to enter if you pass by On the map, you indicated how many mamoul pieces you expect to be forced to eat in each house by your generous relatives and also the number of kids in each house that you will have to give money toYour goal is to get to your grandparents house minimizing the number mamoul pieces that you eat, and also without paying more than the money you dedicated for this Eid.Task DescriptionYou are given the following: The map represented as two D grids of integers, each of size times Ntimes M where each cell corresponds to a house.mamoulij the number of mamoul pieces you are expected to eat at house ijmoneyij the amount of money you expect to pay at house ijAn integer K representing the maximum amount of money you are ready to pay during eid.Assuming that your house is at and your grandparents house is at NM your task is to find the minimum amount of mamoul pieces you must eat going from your house to your grandparents house.ConstraintsYou can move only in the following directions: DOWN, RIGHT, DOWNRIGHT.If the grids have a negative number at position ij then the house at that position is not a house of one of your relatives and you can't pass through it I.e negative numbers represent blocked cells on the map.RequirementsModify mamoul.cpp to implement the following function: int minmamoulint mamoul, int money int N int M int K Return the constant INTMAX in each of the following cases:If there is no path from to NMIf there is no path from to NM whose sum of money values is less than KExamplesExample Input:mamoulmoneyK Result: path shown with astrisks on the grid The diagonal path is invalid: Eidieh cost is K All other paths require eating more mamoul pieces than Example Input:mamoulmoneyK Result: INTMAX no path from to NMExample Input:mamoulmoneyK Result: INTMAX All paths cost K
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started