Answered step by step
Verified Expert Solution
Question
1 Approved Answer
complete the function solve in PYTHON3 only, code snippet and question clearly attached. consider the constraints as multiple hidden test cases need to be passed.
complete the function solve in PYTHON3 only, code snippet and question clearly attached. consider the constraints as multiple hidden test cases need to be passed.
everything is clearly mentioned in the snapshots.
End Question 1 Max. score: 100.00 Minimum Cost to reach destination Problem Statement: Ram is current at city 1 and wants to reach city N. While crossing cities he can either go from city i to city 1+1 by spending cost cior use a bridge that connects city / to city ja >1). Each bridge has its own travel cost. Ram doesn't likes to travel from bridges much so he decides not to take more than K bridges during his journey. Since Ram is on a tight budget can you help Ram find out the minimum cost to reach city N. Example Assume that N = 3, M = 1, K = 1, C = (2,4) Bridges: 135 The cost of going from 1 to 3 using connections is 6, or we can use 1 bridge and go from 1 to 3 using cost 5. There the answer is 5. Function description Complete the solve function provided in the editor. This function takes the following 5 parameters and returns the minimum cost Ram needs to reach city N . N. Represents the number of cities M: Represents the number of bridges. K: Represents the number of bridges that can be atmost used C: An array representing the cost of connection of i and i+1 city . b: A 2D array, with each row denoting the bridge between 2 cities and its cost Input Format: Note: This is the input format that you must use to provide custom input (available above the Compile and Test button). The first line of the input contains N, Mand K-the number of cities, the total number of bridges and the maximum number of bridges you can take. . The second line contains N-1 integers C_1, c2...., _n-1 where is the cost of traveling from city i to city It1. Then M lines follow: Then M lines follow: . Each line contains A, B and D which means that there is a bridge between A and B, and the cost of traveling through that bridge is D. Output Format: Print one integer - the minimum cost Ram needs to spend to reach city N. Constraints 13->4->5). Total cost will be ( 2+1+4 = 7) 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