Question: complete the function Solve, preferably in Python3 if not Java8. the code snippet is attached for both Python and Java. consider the constraints also as

complete the function Solve, preferably in Python3 if not Java8. the code snippet is attached for both Python and Java. consider the constraints also as multiple hidden test cases need to be passed.  complete the function Solve, preferably in Python3 if not Java8. the
code snippet is attached for both Python and Java. consider the constraints
also as multiple hidden test cases need to be passed. everything is
mentioned in the attached images. please be specific on what information you
need 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 H1 by spending cost
everything is mentioned in the attached images. please be specific on what information you need

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 H1 by spending cost or use a bridge that connects city / to city 0 > ). 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 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 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, 2..... C..n-1 where is the cost of traveling from city / to city H1 3 Then M lines follow: 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, c_2..., C_n-1 where c_/ is the cost of traveling from city i to city H+1. 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 ( 241+4 = 7) Note: Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement Time Limit: 10 sec(s) for each input file Memory Limit: 256 MB Source Limit: 1024 KB Marking Schemer Score is assigned if any testcase passes Allowed Languages: Go, Java, Java 8, Java 14. Python Python 3, Python 3.8 ? Save Python 3 (python 3.5.2) 1 Hef solve (N, M, K, c, b): 2 # Write your code here 3 4 5 N,M,K = map (int, input().split() I 6 c = list(map(int, input().split())) b = [list(map(int, input().split())) for i in range (M)] 8 9 out = solve(N, M, K, C, b) 10 print (out) Save 1 2 3 Java 8 (oracle 1.8.0_131) import java.io.*; import java.util.*; public class TestClass { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in ); PrintWriter wr = new Printwriter(System.out); String[] = br.readLine().split(" "); int N = Integer.parseInt(ip[0]); int M Integer.parseInt(ip[1]); int K = Integer.parseInt(ip[2]): String[] arr_c = br.readLine().split(" "); int[] c = new int[N-1); for(int i c = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!