Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Plz provide the solution ASAP . It is ver urgent Description Problem Statement You are given a graph of Cities. The cities are numbered from

Plz provide the solution ASAP .It is ver urgent
Description
Problem Statement
You are given a graph of Cities. The cities are numbered from 1 to N. You are in the City 1. You have M routes, which come along with a cost. You have a special talent where you get the cost of the routes you move in. Find the maximum cost you can acquire by moving from City 1 to City N.
Note: You can assume that it's always possible to reach from City 1 to City N. However, if you can get an arbitrarily large score, return -1.
Input Format
The first line contains an integer N, the total number of Cities.
The second line contains an integer M, the total number of routes.
The third line contains an integer 3, representing that there will be 3 integers in the next M lines.
The next M lines contains 3 integers ABC - representing a route from A to B with a cost of C.
Output Format
The maximum cost you can acquire by moving from City 1 to City N.
Constraints
1N2500
1M5000
1A,BN
-1000000000C1000000000
Evaluation Parameters
Sample Input
4
5
3
123
2,4,-1
13-2
347
144
Sample Output
5
Explanation
If we see the graph, The maximum Cost we can acquire is 5, We can move from 1 to 3 and 3 to 4, that will give the maximum cost.
Execution time limit
Default
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

Draw a labelled diagram of the Dicot stem.

Answered: 1 week ago

Question

Define self-esteem and discuss its impact on your life.

Answered: 1 week ago